This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6420] New: Mtrace deadlock
- From: "mjambor at suse dot cz" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 17 Apr 2008 10:18:32 -0000
- Subject: [Bug libc/6420] New: Mtrace deadlock
- Reply-to: sourceware-bugzilla at sourceware dot org
Different locking order of mtrace lock and dl_load_lock can cause
deadlocks when mtrace is enabled.
The reason is that at the moment mtrace hooks acquire both locks, they
lock their own lock (called lock) first and then call _dl_addr() which
in turn locks dl_load_lock. However, there is at least one place
where such a hook is triggered with dl_load_lock already locked. That
place is a call to malloc() in function add_dependency() in
dl-lookup.c and there may be others. This results into a different
lock ordering and therefore a potential deadlock.
Unfortunately I cannot reproduce this deadlock myself but it did
happen to one of our customers and it also did go away when we fixed
the problem. Although they were using glibc 2.3.3 I noticed the
problem is present in the CVS version too and so decided to file a bug
here.
The fix is in fact simple. Mtrace hooks do not need to call _dl_addr
while also holding its own lock and so we can avoid this problem by
calling _dl_addr before locking lock and print it afterwards (when
holding the lock). The only slight problem is one of taste. The fact
that _dl_addr and the structure it returns, Dl_info, are available
only when HAVE_ELF macro is defined, makes direct change of the code
very ugly. Therefore I am about to attach two patches that fix the
problem. The first merely splits the function tr_where to three
smaller ones. The second then actually changes the behavior as
described above.
--
Summary: Mtrace deadlock
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: mjambor at suse dot cz
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6420
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.