Bug 790837
Summary: | Use of atexit to clean up handles is wrong in multithreaded programs | ||
---|---|---|---|
Product: | [Community] Virtualization Tools | Reporter: | Richard W.M. Jones <rjones> |
Component: | libguestfs | Assignee: | Richard W.M. Jones <rjones> |
Status: | NEW --- | QA Contact: | |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | unspecified | CC: | virt-maint |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | Type: | --- | |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Richard W.M. Jones
2012-02-15 14:13:50 UTC
I studied this problem and I cannot see a simple way to fix this and to clean up handles when a program exits suddenly. In order to meaningfully clean up, we need to not just kill qemu, but also free all temporary directories in use. The latter essentially requires that we close the handles, but that is not possible if threads are running and using those handles. I also tried to use a gcc destructor instead of an atexit handler, but these behave exactly the same way. In libguestfs >= 1.21, both 'virt-df' and 'virt-alignment-scan' are very prone to core dumping because of this bug. The reason is that these programs are now highly multi-threaded[1]. If there is any error, they call exit(EXIT_FAILURE) which causes close_handles() to be called, closing handles which are in use in other threads. [1] http://rwmj.wordpress.com/2013/02/26/new-in-libguestfs-1-21-15-parallel-virt-df-and-virt-alignment-scan/ |