On Friday, September 28, 2018 at 4:12:31 PM UTC+2, Ian Lance Taylor wrote: > > On Fri, Sep 28, 2018 at 7:08 AM, changkun <euryu...@gmail.com > <javascript:>> wrote: > > > > 1. Is my suspicion reasonable and correct? > > I wouldn't be my first guess. You say that pango memory is > per-thread. That suggests that you need to always call pango on a > consistent thread.
Not really, the original C code calls pango in every new created thread. After involving cgo, it doesn’t change anything of this calling behavior. The pango call is per-thread, according to its document, it is literally a per-thread singleton and only allocate in the first call in every different thread if I read the document correctly: https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html#pango-cairo-font-map-get-default > That will not happen by default. You likely need > to arrange to make all your pango calls from a single goroutine, and > have that goroutine first call runtime.LockOSThread. > Tried, it doesn’t work. A goroutine is created for the cgo call purpose, which instantly entering C side, when C code creates a thread, then call pango inside that thread. > > > 2. Why an error when involving cgo? > > My first guess would be that it is because you are calling the cgo > code from different threads. > Nope. It is all about from Go to C then C doing something without sending data back to Go. I am not calling Go from C. > > 3. Are memories in a non-Go thread completely isolated to Go > > memory per-non-Go thread? > > Sorry, I don't understand this question. > > I was trying to express that, are memories in every non-Go thread are isolated one another? The warning from pango: (process:1): GLib-GObject-WARNING **: cannot register existing type 'PangoFontMap' Looks like that the pango call is double registering the font map object. If the memory are shared across all non-Go thread, it cloud be an issue, isn’t it? Best, changkun -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.