tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dlopen() and libpthread



On Mon, Oct 22, 2012 at 09:58:50AM +0000, Emmanuel Dreyfus wrote:
> On Mon, Oct 22, 2012 at 08:40:27AM +0000, Emmanuel Dreyfus wrote:
> > I also bet that Linux behavior must allow dlopen() of libpthread followed
> > by a thread startup.
> 
> I confirm that: I crafted a test program that dlopen a DSO which calls
> pthread_create, it works very well on Linux.

Does it really work?
Are there mutex inside malloc() that stop the 'arena' getting corrupted
if two threads allocate memory at the same time?
Or does linux take the hit of such mutex for non-threaded programs.

One way to try and hit the mutex that protect malloc is to try
calling malloc from a signal handler (also not allowed).
With mutex in malloc it is likely to deadlock.
Without mutex it is likely to corrupt the arena.
However some malloc implementations may try to use multiple arena's
(to get better concurrency in threaded programs) so the errors might
be difficult to hit.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index