On 07/05/2013 08:00 AM, Laine Stump wrote: > On 07/04/2013 01:43 AM, Caizhifeng wrote: >> Hi ALL, >> >> In order to catch the calltrace of deadlock in libvirtd, I modified the function virMutexLock as follows: >> >> >> But, unfortunatly, sometimes, deadlock happened in child process after virFork, > > The problem is that backtrace() is not "async signal safe". The section > "Async-signal-safe functions" of "man 7 signal" explains what this is in > the context of a signal handler, but the conditions in a child process > just after fork() are really the same - a lock was acquired in one > thread of the parent, then *while that lock is being held* a different > thread of the parent calls fork(), which duplicates all of the process' > memory (including the lock) then creates a new process. In the new > process, the lock comes into existence marked as being held, but there > is no thread to unlock it, so when the child attempts to acquire the > lock, it waits forever. FYI, I'm in the middle of fixing such a bug in our usage of virSetUIDGID, which is another instance of calling a non-async-safe function after fork. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list