Skip to content
  • Ting-Wei Lan's avatar
    gtestdbus: Fix watcher crash on FreeBSD · 91474038
    Ting-Wei Lan authored and Philip Withnall's avatar Philip Withnall committed
    In file gio/gtestdbus.c, function watch_parent, there is a loop which
    waits for commands sent from the parent process and kills all processes
    recorded in 'pids_to_kill' array on parent process exit. The detection
    of parent process exit is done by calling g_poll and checking whether
    the returned event is G_IO_HUP. However, 'revents' is a bit mask, and
    we should use a bitwise-AND check instead of the equality check here.
    
    It seems to work fine on Linux, but it fails on FreeBSD because the
    g_poll returns both G_IO_IN and G_IO_HUP on pipe close. This means the
    watcher process continues waiting for commands after the parent process
    exit, and g_io_channel_read_line returns G_IO_STATUS_EOF with 'command'
    set to NULL. Then the watcher process crashes with segfault when calling
    sscanf because 'command' is NULL. Since the test result is already
    reported by the parent process as 'OK', this kind of crash is likely to
    be unnoticed unless someone checks dmesg messages after the t...
    91474038