[libvirt] [libvirt-1.0.5]deadlock in child process after call function backtrace, any suggestions is appreciate!

Eric Blake eblake at redhat.com
Mon Jul 8 13:48:59 UTC 2013


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130708/40f63382/attachment-0001.sig>


More information about the libvir-list mailing list