After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778653 - ephy_downloads_manager_acquire_session_inhibitor: assertion failed: (manager->inhibitor_cookie == 0)
ephy_downloads_manager_acquire_session_inhibitor: assertion failed: (manager-...
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Downloads
3.22.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
: 783455 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-02-15 09:46 UTC by Andres Gomez
Modified: 2017-07-02 17:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
BT from gdb for epiphany (227.43 KB, text/plain)
2017-02-15 09:46 UTC, Andres Gomez
  Details
downloads-manager: Add another assert (1.31 KB, patch)
2017-02-15 17:36 UTC, Michael Catanzaro
committed Details | Review
Another BT from gdb for epiphany (242.14 KB, text/plain)
2017-06-15 08:52 UTC, Andres Gomez
  Details
downloads-manager: Fix crash when download fails (2.30 KB, patch)
2017-07-02 17:09 UTC, Michael Catanzaro
committed Details | Review

Description Andres Gomez 2017-02-15 09:46:44 UTC
Created attachment 345788 [details]
BT from gdb for epiphany

Epiphany 3.22.5 and WebKit 2.15.4

And the env variable:

"export G_DEBUG=fatal-criticals"

The compilation was done with CMake args:

'-DPORT=GTK -DCMAKE_BUILD_TYPE=Release -DENABLE_MINIBROWSER=ON -DCMAKE_C_FLAGS_RELEASE="-O0 -g -DNDEBUG  -DG_DISABLE_CAST_CHECKS" -DCMAKE_CXX_FLAGS_RELEASE="-O0 -g -DNDEBUG -DG_DISABLE_CAST_CHECKS"'

After visiting several pages, eventually, I try to download a PDF from a link and epiphany hits a SIGSEV.
Comment 1 Michael Catanzaro 2017-02-15 17:29:36 UTC
Are you able to get a backtrace with debug symbols for this one? It should be impossible to hit this case; I don't see how it could possibly ever happen. The functions are simple:

static void
ephy_downloads_manager_acquire_session_inhibitor (EphyDownloadsManager *manager)
{
  if (++manager->inhibitors > 1)
    return;

  g_assert (manager->inhibitor_cookie == 0);
  manager->inhibitor_cookie = gtk_application_inhibit (GTK_APPLICATION (ephy_embed_shell_get_default ()),
                                                       NULL,
                                                       GTK_APPLICATION_INHIBIT_LOGOUT | GTK_APPLICATION_INHIBIT_SUSPEND,
                                                       "Downloading");

  if (manager->inhibitor_cookie == 0)
    g_warning ("Failed to acquire session inhibitor for active download. Is gnome-session running?");
}

static void
ephy_downloads_manager_release_session_inhibitor (EphyDownloadsManager *manager)
{
  if (--manager->inhibitors > 0)
    return;

  if (manager->inhibitor_cookie > 0) {
    gtk_application_uninhibit (GTK_APPLICATION (ephy_embed_shell_get_default ()),
                               manager->inhibitor_cookie);
    manager->inhibitor_cookie = 0;
  }
}

The variables are not modified from any other functions. Am I missing a simple logic mistake there?

I'm also very confused why you have no debug symbols for Epiphany when you compiled with -O0 -g.
Comment 2 Michael Catanzaro 2017-02-15 17:31:41 UTC
Ah wait, inhibitors is a guint and can underflow if _release_session_inhibitor() is called before _acquire_session_inhibitor(). I guess something funky could cause that.
Comment 3 Michael Catanzaro 2017-02-15 17:35:59 UTC
The following fix has been pushed:
7221b57 downloads-manager: Add another assert
Comment 4 Michael Catanzaro 2017-02-15 17:36:03 UTC
Created attachment 345857 [details] [review]
downloads-manager: Add another assert

Something is wrong here. This assert will help catch it.
Comment 5 Michael Catanzaro 2017-02-15 17:41:28 UTC
So I added a new assert. Now it will crash sooner next time this bug occurs. Please apply the patch and post another backtrace when it happens again!
Comment 6 Andres Gomez 2017-02-16 08:44:31 UTC
(In reply to Michael Catanzaro from comment #1)
> I'm also very confused why you have no debug symbols for Epiphany when you
> compiled with -O0 -g.

Sorry, copy & paste. It is indeed not that clear.

Those are the compilation flags for WebKit, not epiphany. Epiphany was not built with debug symbols.
Comment 7 Andres Gomez 2017-02-16 08:46:07 UTC
(In reply to Michael Catanzaro from comment #5)
> So I added a new assert. Now it will crash sooner next time this bug occurs.
> Please apply the patch and post another backtrace when it happens again!

I'll apply and build with debug symbols. In any case, this is not that easy to reproduce so, let's see if I can ...
Comment 8 Andres Gomez 2017-06-15 08:52:12 UTC
Created attachment 353806 [details]
Another BT from gdb for epiphany

Epiphany 3.24.1 and WebKit 2.17.3
Comment 9 Carlos Garcia Campos 2017-06-15 09:02:38 UTC
The inhibitor is acquired on created-destination, so in case of failure or cancellation, if it happened before the destination is created, the release is unbalanced.
Comment 10 Michael Catanzaro 2017-06-15 13:30:57 UTC
*** Bug 783455 has been marked as a duplicate of this bug. ***
Comment 11 Michael Catanzaro 2017-07-02 17:08:59 UTC
The following fix has been pushed:
b7e269f downloads-manager: Fix crash when download fails
Comment 12 Michael Catanzaro 2017-07-02 17:09:05 UTC
Created attachment 354800 [details] [review]
downloads-manager: Fix crash when download fails

It's wrong to acquire the session inhibitor when destination is created,
because the download could fail before that point, causing the
inhibitotr to be released before it has been acquired and triggering our
assertions to ensure this does not happen.

Instead, acquire the inhibitor immediately when creating the download.