IBBoard / cawbird

A fork of the Corebird GTK Twitter client that continues to work with Twitter
https://ibboard.co.uk/cawbird/
GNU General Public License v3.0
309 stars 37 forks source link

Crash when first signing in #399

Closed stuartlangridge closed 2 years ago

stuartlangridge commented 2 years ago

Describe the bug When I sign into Cawbird, after entering the Twitter PIN, it crashes. Restarting after that, the app is signed in.

To Reproduce Steps to reproduce the behavior:

  1. Start Cawbird for the first time
  2. Hit "Request PIN"
  3. Authorise Cawbird in the browser to get a PIN
  4. Enter the PIN into Cawbird
  5. Cawbird crashes (a terminal says "Segmentation fault (core dumped)")

Expected behavior No crash.

System details:

Running G_MESSAGES_DEBUG=cawbird cawbird can give useful debug output.

Messages displayed from this when I enter the pin are:

(cawbird:1168707): cawbird-DEBUG: 06:34:48.903: REST: GET 1.1/account/settings.json
(cawbird:1168707): cawbird-DEBUG: 06:34:49.032: AccountCreateWidget.vala:121: Checking for sil
(cawbird:1168707): cawbird-DEBUG: 06:34:49.032: REST: GET 1.1/account/verify_credentials.json
(cawbird:1168707): cawbird-DEBUG: 06:34:49.168: Account.vala:308: Using https://pbs.twimg.com/profile_images/55108762/hackergotchi-simpler_normal.png to update the avatar(old: https://pbs.twimg.com/profile_images/55108762/hackergotchi-simpler_normal.png)
(cawbird:1168707): cawbird-DEBUG: 06:34:49.168: AccountCreateWidget.vala:162: user info call
(cawbird:1168707): cawbird-DEBUG: 06:34:49.169: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 1
(cawbird:1168707): cawbird-DEBUG: 06:34:49.193: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 2
(cawbird:1168707): cawbird-DEBUG: 06:34:49.201: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 3
(cawbird:1168707): cawbird-DEBUG: 06:34:49.206: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 4
(cawbird:1168707): cawbird-DEBUG: 06:34:49.211: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 5
(cawbird:1168707): cawbird-DEBUG: 06:34:49.219: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 6
(cawbird:1168707): cawbird-DEBUG: 06:34:49.226: Database.vala:47: Executing /uk/co/ibboard/cawbird/sql/accounts/Create.%d.sql for 7
(cawbird:1168707): cawbird-DEBUG: 06:34:49.256: Creating stream for sil
Segmentation fault (core dumped)
IBBoard commented 2 years ago

Can you try the Cawbird Unstable package and see whether that fixes it? There's some other messages that I'd expect to see if it was related to #391, but it's worth a check.

Other than that then I'll need the stack trace at the time it segfaulted. Can you run gdb /usr/bin/cawbird /path/to/corefile (or coredumctl gdb -1 if you're on a systemd distro, which I think Ubuntu should be) and then run bt, copy the backtrace here and then run quit to quit.

stuartlangridge commented 2 years ago

I have tried the unstable package and it does not help, I'm afraid; the issue still happens.

I don't understand the gdb instructions, though (I'm not a C person). I had to install systemd-coredump to get coredumpctl (which removed apport and apport-gtk, which is a bit worrying, and hopefully I can put them back afterwards so I still get bug reporting?), but then I don't know what to run:

~ $ coredumpctl gdb -1 /usr/bin/cawbird
No match found.
~ $ coredumpctl gdb -1
No match found.

Do I need to run cawbird and make it crash first, and then point gdb at the core file that is dumped? I tried, but I don't know where that core file is. It doesn't seem to be written to the current directory; apport writes things to /var/crash but it's not in there either.

IBBoard commented 2 years ago

Apport apparently collects coredumps, so maybe Ubuntu has a different way of doing it. I thought I'd seen that coredumpctl was the standard on systemd systems. It might be worth re-installing apport and then following these instructions that I've just found to enable core dumps on Ubuntu. Based on the Apport wiki page it might even have the stack trace visible in one of the detail sections.

stuartlangridge commented 2 years ago

OK. So, what I did (for future reference) was:

  1. sudo apt install apport apport-gtk (this wouldn't be needed by someone who hadn't installed systemd-coredump, but I had, so this resets things back to normal)
  2. ulimit -c unlimited
  3. cawbird (in the same terminal window as the ulimit command)
  4. replicate the bug
  5. in the current directory there is now a file called core
  6. gdb /usr/bin/cawbird core
  7. At prompt --Type <RET> for more, q to quit, c to continue without paging-- I hit Enter to continue
  8. At prompt (gdb), enter bt
  9. At prompt --Type <RET> for more, q to quit, c to continue without paging-- I hit Enter to continue
  10. At prompt (gdb), enter quit
  11. Then copy all the output below:
14:22 ~/Sc+/cor $ gdb /usr/bin/cawbird core
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/cawbird...
(No debugging symbols found in /usr/bin/cawbird)
[New LWP 1838127]
[New LWP 1838128]
[New LWP 1838130]
[New LWP 1838131]
[New LWP 1838153]
[New LWP 1838129]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--Type <RET> for more, q to quit, c to continue without paging--
Core was generated by `cawbird'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055b2dfff13e9 in ?? ()
[Current thread is 1 (Thread 0x7fddcb46a440 (LWP 1838127))]
(gdb) bt
#0  0x000055b2dfff13e9 in  ()
#1  0x000055b2e001508e in  ()
#2  0x000055b2dfff45d0 in  ()
#3  0x00007fddcfb09802 in g_closure_invoke ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4  0x00007fddcfb1d814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#5  0x00007fddcfb28bbe in g_signal_emit_valist ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007fddcfb29b9c in g_signal_emit_by_name ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x000055b2e002b894 in  ()
#8  0x00007fddcfc09f49 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#9  0x00007fddcfc0ab3d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#10 0x000055b2e000b5de in  ()
#11 0x00007fddcfc09f49 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#12 0x00007fddcfc09f8d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#13 0x00007fddd081004e in g_main_context_dispatch ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007fddd0810400 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007fddd08104a3 in g_main_context_iteration ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007fddcfc37fe5 in g_application_run ()
    at /lib/x86_64-linux-gnu/libgio-2.0.so.0
--Type <RET> for more, q to quit, c to continue without paging--
#17 0x000055b2dffef189 in  ()
#18 0x00007fddcf3190b3 in __libc_start_main (main=
    0x55b2dffeefe0, argc=1, argv=0x7ffc7d726a58, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7ffc7d726a48)
    at ../csu/libc-start.c:308
#19 0x000055b2dffef02e in  ()
(gdb) quit

This was done with cawbird-unstable installed from the deb for Ubuntu 20.04.

IBBoard commented 2 years ago

Thanks for those Ubuntu steps 🙂

Unfortunately, nothing in that list references Cawbird code, so I still can't tell from that what broke. But there are several steps without any source line and with different memory locations (0x000055…), which could be our code. Could you install the cawbird-unstable-dbg package to get the debug symbols and try again?

stuartlangridge commented 2 years ago

(With debug package installed, which I got by poking the URL to get https://software.opensuse.org//download.html?project=home%3AIBBoard%3Acawbird-unstable&package=cawbird-unstable-dbg -- it might be useful to add a link to that to the readme so people can find it when doing these debug steps?)

Hopefully this is a more useful backtrace!

14:35 ~/Sc+/cor $ cawbird

(cawbird:1856274): cawbird-WARNING **: 14:35:20.537: Cawbird.vala:441: Could not add window for account 'sil'

(cawbird:1856274): Gdk-CRITICAL **: 14:35:20.541: gdk_window_get_window_type: assertion 'GDK_IS_WINDOW (window)' failed
Segmentation fault (core dumped)
14:35 ~/Sc+/cor $ ls
core
14:35 ~/Sc+/cor $ gdb /usr/bin/cawbird core
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/cawbird...
Reading symbols from /usr/lib/debug/.build-id/3e/048ab35e577a7cdf451723ea52ca1b778293e4.debug...
[New LWP 1856274]
[New LWP 1856275]
[New LWP 1856276]
[New LWP 1856277]
[New LWP 1856278]
[New LWP 1856287]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--Type <RET> for more, q to quit, c to continue without paging--
Core was generated by `cawbird'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055d9600d93e9 in cawbird_is_window_open_for_user_id (
    self=self@entry=0x55d961bab1b0, user_id=1389781, window=window@entry=0x0)
    at cawbird@sta/src/Cawbird.c:2446
2446    cawbird@sta/src/Cawbird.c: No such file or directory.
[Current thread is 1 (Thread 0x7fefd254f440 (LWP 1856274))]
(gdb) bt
#0  0x000055d9600d93e9 in cawbird_is_window_open_for_user_id
    (self=self@entry=0x55d961bab1b0, user_id=1389781, window=window@entry=0x0)
    at cawbird@sta/src/Cawbird.c:2446
#1  0x000055d9600fd08e in user_list_entry_construct_from_account
    (object_type=<optimised out>, acc=acc@entry=0x7fefc400bab0)
    at cawbird@sta/src/list/UserListEntry.c:643
#2  0x000055d9600fd249 in user_list_entry_new_from_account
    (acc=acc@entry=0x7fefc400bab0) at cawbird@sta/src/list/UserListEntry.c:653
#3  0x000055d9600dc5d0 in __lambda235_
    (new_acc=0x7fefc400bab0, self=0x55d961d303a0)
    at cawbird@sta/src/MainWindow.c:887
#4  ___lambda235__cawbird_account_added
    (_sender=<optimised out>, acc=0x7fefc400bab0, self=0x55d961d303a0)
    at cawbird@sta/src/MainWindow.c:908
#5  0x00007fefd6bee802 in g_closure_invoke ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007fefd6c02814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007fefd6c0dbbe in g_signal_emit_valist ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007fefd6c0eb9c in g_signal_emit_by_name ()
    at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x000055d960113894 in __lambda185_
    (_data79_=0x55d961da7600, _data79_=0x55d961da7600, obj=<optimised out>, res=--Type <RET> for more, q to quit, c to continue without paging--
<optimised out>) at cawbird@sta/src/widgets/AccountCreateWidget.c:833
#10 ___lambda185__gasync_ready_callback
    (source_object=<optimised out>, res=<optimised out>, self=0x55d961da7600)
    at cawbird@sta/src/widgets/AccountCreateWidget.c:844
#11 0x00007fefd6ceef49 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#12 0x00007fefd6cefb3d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#13 0x000055d9600f35de in twitter_get_own_user_info_co (_data_=0x55d961ee4200)
    at cawbird@sta/src/Twitter.c:2819
#14 0x00007fefd6ceef49 in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#15 0x00007fefd6ceef8d in  () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#16 0x00007fefd78f504e in g_main_context_dispatch ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007fefd78f5400 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007fefd78f54a3 in g_main_context_iteration ()
    at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007fefd6d1cfe5 in g_application_run ()
    at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#20 0x000055d9600d7189 in _vala_main
    (args=<optimised out>, args_length1=<optimised out>)
    at cawbird@exe/src/main.c:69
#21 0x00007fefd63fe0b3 in __libc_start_main (main=
    0x55d9600d6fe0 <main>, argc=1, argv=0x7fff5ab92c68, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fff5ab92c58)
--Type <RET> for more, q to quit, c to continue without paging--
    at ../csu/libc-start.c:308
#22 0x000055d9600d702e in _start () at cawbird@exe/src/main.c:79
(gdb) quit
14:35 ~/Sc+/cor $ 
IBBoard commented 2 years ago

it might be useful to add a link to that to the readme so people can find it when doing these debug steps?

I'm not sure how many variant instructions we'd need! On openSUSE you install the repo and then the debug package is available in the standard package list (as long as you're not configured to filter them out).

Hopefully this is a more useful backtrace!

It should be. We're definitely seeing our calls now! The backtrace shows that it's in cawbird_is_window_open_for_user_id(). It'll need a little bit of poking to find out what's wrong, though, because that's a Vala class (so the C code is transpiled rather than something we wrote) which should be significantly less prone to segfaults etc.

stuartlangridge commented 2 years ago

I'm not sure how many variant instructions we'd need! On openSUSE you install the repo and then the debug package is available in the standard package list (as long as you're not configured to filter them out).

Ah, fair. I installed the package directly because I didn't want to add the repo -- I normally have the snap installed, and I'll go back to that once I'm not debugging, and I don't like adding repos because I forget I've done it, which is one of the reasons I prefer snaps -- so I had to poke around to find the debug package. I may be unusual in this!

IBBoard commented 2 years ago

There should be some new Cawbird Unstable builds with that patch in appearing on OBS shortly. It looks like you need to wait for cawbird_1.4.1-1+107.1 to appear. In my testing, the account was created anyway so I assume you'll need to delete ~/.config/cawbird/ to remove any existing accounts to test and recreate (note that this obviously deletes existing accounts and everything!)

(And Vala didn't prevent the segfault because we declared the variable as nullable, weren't doing null checks, and didn't see any warnings from Vala about assuming a nullable was non-null)

stuartlangridge commented 2 years ago

OK, confirmed: +107 fixes the issue for me! Looking forward to this hitting stable and then the snap (cc @diddlesnaps :)) so that I can switch back to that, but thank you for the fast fix!

IBBoard commented 2 years ago

No problem 🙂 Crashes are one of the more clear and significant problems to fix!

Thanks for reporting it. Presumably other people hit it as well and just ignored it because (at least for me) things seemed to work fine when you restarted the app.

IBBoard commented 2 years ago

Builds are GO! But I can't do anything about the Snap 🙂