Re: g_list_append() giving SEGV



"Aggarwal , Ajay" <ajay crossbeamsys com> writes:

> Thats exactly how I am using it. Do you know any place where it is
> documented clearly as to which calls from Glib are thread-safe (or not
> thread-safe.

All of GLib is (or is supposed to be) thread safe in the sense that
internal data is properly locked if you call g_thread_init().

That _does not_ mean that the GLib data structures themselves are
automatically locked. (Which would be a big performance hit, and not
even possible for things like GList where the internals are directly
accessible without going through function calls to GLib.)

You can access hash table A from thread A and hash table B from thread
B and things will work fine. But if you want to access hash table A
from both threads, then you need to protect it with a mutex yourself.

Regards,
                                        Owen

> > -----Original Message-----
> > From: Dugas, Alan [mailto:alan dugas analog com]
> > Sent: Monday, October 09, 2000 1:35 PM
> > To: Aggarwal , Ajay
> > Subject: RE: g_list_append() giving SEGV
> > 
> > 
> > g_list_append() may move the address of the list you pass it. 
> >  You might
> > want to check to make sure that after every g_list_append() 
> > call, you update
> > any variables that are supposed to track it.
> > 
> > i.e.	glist_variable = g_list_append(glist_variable, "user data");
> > 
> > Hope this helps.
> > 
> > 
> > 
> > 				-- Stupid Genius
> > > ----------
> > > From: 	Aggarwal , Ajay[SMTP:ajay crossbeamsys com]
> > > Sent: 	Monday, October 09, 2000 12:51 PM
> > > To: 	'gtk-list gnome org'
> > > Subject: 	g_list_append() giving SEGV
> > > 
> > > Does anybody know if glib-1.2.6-3 is thread-safe in 
> > general? I am getting
> > > a
> > > SEGV in g_list_append() call. I am doing g_thread_init() in the very
> > > beginning of my program and g_thread_supported() returns TRUE after
> > > g_thread_init() call.
> > > 
> > > The backtrace looks like:
> > > g_list_append()
> > > g_list_alloc()
> > > g_mem_chuck_alloc()
> > > g_malloc()
> > > _libc_malloc()
> > > chuck_alloc()
> > > chunk_free()
> > > 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]