Bug 1460338 - guestfs_shutdown hangs if main process sets signal handlers
Summary: guestfs_shutdown hangs if main process sets signal handlers
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-09 18:12 UTC by Richard W.M. Jones
Modified: 2017-06-13 15:45 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-13 15:45:16 UTC
Embargoed:


Attachments (Terms of Use)
lvm_guestfs.c (1.33 KB, text/x-csrc)
2017-06-09 18:12 UTC, Richard W.M. Jones
no flags Details
Debugging output (44.70 KB, text/plain)
2017-06-09 18:12 UTC, Richard W.M. Jones
no flags Details

Description Richard W.M. Jones 2017-06-09 18:12:06 UTC
Created attachment 1286485 [details]
lvm_guestfs.c

Description of problem:

(Reported by wtfuzz on IRC)

The attached program fails, but only when an LVM volume
group is open in the main process (using lvm2app).

It seems as if lvm2app fiddles with signal handlers, and
those are inherited by the forked qemu process, preventing
it from seeing the SIGTERM signal that we later send.  So
guestfs_shutdown hangs.

See attached example code and debug.

Version-Release number of selected component (if applicable):

libguestfs 1.32.7 (from Debian)

How reproducible:

100% when lvm_vg_open has been called in the main process.

Comment 1 Richard W.M. Jones 2017-06-09 18:12:36 UTC
Created attachment 1286486 [details]
Debugging output

Comment 2 Richard W.M. Jones 2017-06-09 22:12:47 UTC
From the reporter:

21:25 < wtfuzz> rwmjones: I can confirm that setting up SIGTERM in a sigset_t, and doing a sigprocmask(SIG_UNBLOCK, &mask, NULL) after lvm_vg_open() fixes my issue

Comment 3 Richard W.M. Jones 2017-06-10 17:25:14 UTC
I was able to reproduce this easily with upstream by adjusting
one of the example programs to include this code in main():

  guestfs_set_backend (g, "direct");
  sigemptyset (&set);
  sigaddset (&set, SIGTERM);
  sigprocmask (SIG_BLOCK, &set, NULL);

Note this only affects the 'direct' backend.

Comment 4 Richard W.M. Jones 2017-06-10 17:33:38 UTC
Patch posted upstream:

https://www.redhat.com/archives/libguestfs/2017-June/msg00061.html


Note You need to log in before you can comment on or make changes to this bug.