Bug 835112 - g_dbus_proxy_call_sync() creates a persistent thread
g_dbus_proxy_call_sync() creates a persistent thread
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: glib2 (Show other bugs)
16
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Matthias Clasen
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-25 11:03 EDT by Denys Vlasenko
Modified: 2013-02-13 13:39 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-13 13:39:41 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Denys Vlasenko 2012-06-25 11:03:27 EDT
glib2-devel-2.30.3-1.fc16.i686

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

static GDBusProxy *get_dbus_proxy(void)
{
    GError *error = NULL;
    GDBusProxy *proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
                                         G_DBUS_PROXY_FLAGS_NONE,
                                         NULL,
                                         ABRT_DBUS_NAME,
                                         ABRT_DBUS_OBJECT,
                                         ABRT_DBUS_IFACE,
                                         NULL,
                                         &error);
    if (error) ...
    return proxy;
}

...
    GDBusProxy *proxy = get_dbus_proxy();
    if (!proxy)
        return NULL;
    GError *error = NULL;
    GVariant *result = g_dbus_proxy_call_sync(proxy,
                                    "GetProblems",
                                    g_variant_new("()"),
                                    G_DBUS_CALL_FLAGS_NONE,
                                    -1,
                                    NULL,
                                    &error);
...

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);
            free_run_event_state(run_state);
            if (!no_such_event)
            {
                exit(r);
            }
            /* 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 10:33:52 EST
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: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 2 Fedora End Of Life 2013-02-13 13:39:44 EST
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.