gnubiff applet crashes when mail is received signal 5 in XGetWindowProperty

Bug #1876609 reported by David McKelvie
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnubiff (Ubuntu)
New
Undecided
Unassigned

Bug Description

I had been using gnubiff in the gnome panel in Ubuntu 16.04.
I recently did an in-place upgrade from 16.04 to 18.04.
Now X crashes whenever mail is received.

In place upgrade from Ubuntu 16.04 to 18.04

gnubiff from package gnubiff 2.2.17-build1

In Gnome Flashback (Metacity) display manager.

Add gnubiff to gnome-panel

Then receive mail

Gnubiff icon moves down the panel so its not completely visible.
Then X dies and I'm sent back to the login page.

I try login again and I'm immediately logged out again with the same error.

I can login with Ubuntu ( display manager ) ok
Then I can use dconf-editor to remove gnubiff from the panel
org.gnome.gnome-panel.layout
remove 'gnubiff-applet' from this list.
After that I can login using Gnome Flashback (Metacity)
without error.

Then I get a ubuntu-bug popup

Ubuntu 18.04 has experienced an internal error.
/usr/bin/gnome-panel
gnome-panel crashed with signal 5 in XGetWindowProperty()

Tags: patch
Revision history for this message
David McKelvie (dmck-interactive) wrote :

/var/crash/_usr_bin_gnome-panel.1000.crash

affects: xserver-xorg-driver-vesa → gnome-panel
Revision history for this message
David McKelvie (dmck-interactive) wrote :

If I run
   gnome-panel --replace &
and then add gnubiff to panel (when mail is pending) then I get

---------------------------
(gnome-panel:1856): Gdk-ERROR **: 17:36:46.221:
The program 'gnome-panel' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadImplementation (server does not implement operation)'.
  (Details: serial 3682 error_code 17 request_code 20 (core protocol) minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
-------------------------------

If I run
    GDK_SYNCHRONIZE=1 gnome-panel --replace &
then I get

--------------------------------
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
gnome-panel: ../../src/xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
---------------------------------

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Can you do that in gdb?

gdb gnome-panel
set env GDK_SYNCHRONIZE 1
run --replace
bt full

Revision history for this message
David McKelvie (dmck-interactive) wrote :

Yes indeed, I can. See attachment.

Revision history for this message
David McKelvie (dmck-interactive) wrote : Re: [Bug 1876609] Re: gnubiff applet crashes when mail is received signal 5 in XGetWindowProperty

>> Can you do that in gdb?

Yes indeed. Ive attached the backtrace to
https://bugs.launchpad.net/gnome-panel/+bug/1876609

David

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Install *-dbgsym packages for panel and gtk:
- https://launchpad.net/ubuntu/+source/gnome-panel/1:3.26.0-1ubuntu5
- https://launchpad.net/ubuntu/+source/gtk+3.0/3.22.30-1ubuntu4

And after setting env, add breakpoint:
break gdk_x_error

Revision history for this message
David McKelvie (dmck-interactive) wrote :

OK.

I followed the instructions for getting -dbgsym.ddeb packages
from https://wiki.ubuntu.com/Debug%20Symbol%20Packages

Then Installed

gnome-panel-dbgsym
libgtk-3-0-dbgsym

using synaptic

Then

gdb gnome-panel
set env GDK_SYNCHRONIZE 1
break gdk_x_error
run --replace
bt full

(gdb) break gdk_x_error said

Function "gdk_x_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (gdk_x_error) pending.

This gave me

Thread 1 "gnome-panel" hit Breakpoint 1, gdk_x_error (xdisplay=0x5555557f38f0, error=0x7fffffffc320)
    at ../../../../../gdk/x11/gdkmain-x11.c:272
272 ../../../../../gdk/x11/gdkmain-x11.c: No such file or directory.

The backtrace is attached.

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Please install also libwnck debug symbols.

Revision history for this message
David McKelvie (dmck-interactive) wrote :

There seem to be two errors.
Whether they are independant or related I don't know.

1) Error 1: when adding gnubiff applet to panel and no pending email

I.e. gnubiff is not in panel. There is no pending email.
gnome-panel is started in gdb
gnubiff is added to panel using 'Add to Panel'

This is

XGetWindowProperty
read_rgb_icon
_wnck_read_icons

and full backtrace is in 'Error 1 Attachment'

2) Error 2: When gnubiff applet is in the panel already and email is received.

I.e. gnubiff is already in panel. There is no pending email.
gnome-panel is started in gdb.
Mail is received

This is the poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' error

XGetWindowProperty
get_current_desktop
gdk_x11_screen_get_work_area

and backtrace is in 'Error 2 Attachment'

Revision history for this message
David McKelvie (dmck-interactive) wrote :

Error 2 Attachment

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

In first case, is it possible to continue in gdb? XGetWindowProperty in read_rgb_icon is protected with error trap, so I think at that place it should not crash. Crash most likely is somewhere else.

Second backtrace also looks weird to me... Is applet using multiple threads?

I will try to look at applet code.

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Ok, no idea what exactly has changed and where, but I think problem is in applet...

Check AppletGnome::update, it tries to lock mutex. So I guess it is indication that function is called from multiple threads.

Then multiple files / places has this:
gdk_threads_enter();
biff_->applet()->update();
gdk_threads_leave();

https://developer.gnome.org/gdk3/stable/gdk3-Threads.html
It says that GTK should be used from thread that called gtk_init and gtk_main.

I guess there is no code in panel or any other place that calls gdk_threads_init. If that is true then gdk_threads_enter and gdk_threads_leave does nothing. Quick test could be to rebuild panel by adding gdk_threads_init before gtk_init.

Real fix would be to update applet/gnubiff to not use GTK from other threads... Maybe AppletGnome::update could use g_idle_add to add callback that will be called in main thread?

Revision history for this message
David McKelvie (dmck-interactive) wrote :

I think that the applet does use multiple threads in order to read mailboxes. It certainly contains references to gdk_threads_enter and gdk_threads_leave (both of which are deprecated :-).

In Error 1, if I continue from error in read_rgb_icon
I get another error in _wnck_get_utf8_property at xutils.c:388
then an error in _wnck_get_text_property at xutils.c:304
then an error in _wnck_get_utf8_property at at xutils.c:388
and so on with various errors.

So basically, tho one can continue, something is wrong.

Revision history for this message
David McKelvie (dmck-interactive) wrote :

Alberts, thank you for looking at this. I'll try the gdk_threads_init patch to gnome-panel you suggest and then read up on how to use g_idle_add.

Revision history for this message
David McKelvie (dmck-interactive) wrote :

I modified gnome-panel/main.c:

        g_option_context_add_group (context, gtk_get_option_group (TRUE));
        g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

+ gdk_threads_init(); // Added by David for gnubiff
        gtk_init (&argc, &argv);

        /* FIXME: High dpi scaling does not work... */
        gdk_x11_display_set_window_scale (gdk_display_get_default (), 1);

Rebuilt and installed the modified .deb files.

Now, I can receive email and the gnubiff applet says there is mail (ie the icon changes).
So definite progress. The panel seems fine after the mail has been received.

However I then get an Ubuntu error (from apport)
gnome-flashback crashed with SIGSEGV in g_str_equal()

I am not sure if this error happens on subsequent emails being received or not.

I attach the back trace

affects: gnome-panel → gnome-panel (Ubuntu)
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :
Revision history for this message
David McKelvie (dmck-interactive) wrote :

The following patch to gnubiff fixes this problem, without requiring a change to gnome-panel.

Fix bug Launchpad 1876609
"gnubiff applet crashes when mail is received signal 5 in XGetWindowProperty"

    Use g_idle_add instead of gdk_threads_enter / gdk_threads_leave
    so that gnome-panel does not need to call gdk_threads_init.

    I have not changed gnubiff.cc as it does call gdk_threads_init
    and not changed gtk_image_animation.cc as I dont quite understand
    what it is doing.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "gnubiff-patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Do you want a stable update for Ubuntu 18.04?

Or if you also manage to port it from GConf to GSettings, I can add your patch to 20.04 and/or 20.10 releases.

affects: gnome-panel (Ubuntu) → gnubiff (Ubuntu)
Revision history for this message
David McKelvie (dmck-interactive) wrote :

Hi Dmitry;

>> Do you want a stable update for Ubuntu 18.04?

Let's see. Ive now got a working version because Im running
my locally patched version. So I dont need a new stable release.

On the other hand, the current Ubuntu 18.04 version is broken,
ie it just doesnt work in the gnome-panel. So a release could be helpful for
other people.

I have some other patches as well e.g.
* The missing icon in the 'Add to Panel' menu.
* The popup window not being resized properly when mail messages
are received
https://bugs.launchpad.net/ubuntu/+source/gnubiff/+bug/1362074

Then there is a so far unaddressed bug, which is that the buttons on the
gnubiff preferences window do not work when the preferences window
is opened from the icon in the panel.

>> Or if you also manage to port it from GConf to GSettings,
>> I can add your patch to 20.04 and/or 20.10 releases.

OK, I'll take a look at porting to GSettings since I'd like to have this
functionality in Ubuntu 20.x. I'll need to do some reading.
Are you open to be asked questions now and then?

David

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

> On the other hand, the current Ubuntu 18.04 version is broken, ie it just doesnt work in the gnome-panel. So a release could be helpful for other people.

If you personally don't need a new update for 18.04, then I would not do it. 18.04 is the previous LTS version and I don't have enough time to care about old versions.

> OK, I'll take a look at porting to GSettings since I'd like to have this functionality in Ubuntu 20.x. I'll need to do some reading.
> Are you open to be asked questions now and then?

I do not always respond quickly (and maybe I'm also not an expert in GLib API) but I will do my best.

https://developer.gnome.org/gio/stable/ch34.html should help you with porting.

I am also not sure if all your patches will match the stable release update criteria for 20.04. But I will be definitely able to apply them for 20.10.

Also if you have a SourceForge account you may try to forward them to https://sourceforge.net/p/gnubiff/patches/, but upstream seems to be dead :(

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.