Bug 835112 - g_dbus_proxy_call_sync() creates a persistent thread
Summary: g_dbus_proxy_call_sync() creates a persistent thread
Alias: None
Product: Fedora
Classification: Fedora
Component: glib2
Version: 16
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Matthias Clasen
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2012-06-25 15:03 UTC by Denys Vlasenko
Modified: 2013-02-13 18:39 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-02-13 18:39:41 UTC

Attachments (Terms of Use)

Description Denys Vlasenko 2012-06-25 15:03:27 UTC

We (abrt project) use syncronous dbus calls in a single-threaded application.

static GDBusProxy *get_dbus_proxy(void)
    GError *error = NULL;
    GDBusProxy *proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
    if (error) ...
    return proxy;

    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return NULL;
    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,

We discovered that sometime after we do such calls (and they work successfully, no problem), our application hangs after fork().

The hanging code looks like this:

        pid_t pid = fork();
        if (pid < 0) /* error */...
        if (pid == 0) /* child */
            struct run_event_state *run_state = new_run_event_state();
            int r = run_event_on_dir_name(run_state, dirname, "open-gui");
            int no_such_event = (r == 0 && run_state->children_count == 0);
            if (!no_such_event)
            /* Default: launch graphical tool */
            execlp("report-gtk", "report-gtk", "--", (char *)dirname, NULL);
            perror_msg_and_die("Can't execute %s", "report-gtk");

Child process gets stuck on a futex() call soon after fork() - we do not reach run_event_on_dir_name() and execlp().

Even when parent process is gone, the still-living child remains visible in ps output.

This bug disappears under strace and when debug logging is added. Basically, it looks like a non-deterministic inconsistent lock state in the child.

After investigating the problem we discovered that our program is not single-threaded anymore (!!!) - glib created a thread in g_dbus_proxy_new_for_bus_sync() or in g_dbus_proxy_call_sync() function, and this thread persists for the lifetime of the program. I see it in ps -AT output.

Stracing shows a fair amount of futex ops in this thread. So, it is capable of locking and unlocking locks while we fork() - classic cause of PITA when threading and fork() are mixed.

We wrote the program as a single-threaded one exactly because we wnated to avoid going there.

When we run the program so that it does not use dbus ("abrt-gui -D /var/spool/abrt"), this thread is not created, and the buggy behavior does not trigger.

Can you guys please make *syncronous* glib dbus API to not create threads? Or at least nuke these threads when they are done?

If it is a performance hit to repeatedle create and tear them down, consider exposing a nuke_stupid_thread_I_did_not_ask_for()-esque function in the API so that we can still enjoy the simplicity of single-threaded life?

Comment 1 Fedora End Of Life 2013-01-16 15:33:52 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Comment 2 Fedora End Of Life 2013-02-13 18:39:44 UTC
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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