robert7 / nixnote2

Nixnote - Evernote desktop client for Linux
GNU General Public License v3.0
297 stars 31 forks source link

regression since v2.1.9: nixnote2 no longer exiting cleanly (terminated by SIGABRT) #208

Open ludovicaelbrecht opened 1 year ago

ludovicaelbrecht commented 1 year ago

Expected vs. actual behavior

Up until 2.1.8, when I exit nixnote (File->Quit or Ctrl+Q) it terminates cleanly. Since 2.1.9 it gets terminated by a SIBABRT signal when I exit it.

Running nixnote2 on Linux (Fedora 38).

Here's what it looks line on 2.1.8:

ludovic@x1 /u/s/l/nixnote2 ((v2.1.8))> ./appdir/usr/bin/nixnote2
INFO  2023-07-03 11:59:13.780 src/utilities/crossmemorymapper.cpp:62 Shared memory segment allocated, instance key: "foo"
INFO  2023-07-03 11:59:13.781 src/main.cpp:304 NixNote 2.1.8-94b1c62f, build at Jul  3 2023 at 11:39:44, with Qt 5.15.10 running on 5.15.10
INFO  2023-07-03 11:59:13.781 src/main.cpp:307 To get more detailed startup logging use --logLevel=1
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
INFO  2023-07-03 11:59:17.297 src/main.cpp:375 main: Exit: retcode=0
ludovic@x1 /u/s/l/nixnote2 ((v2.1.8))>

What it looks like on the develop branch and on 2.1.9:

ludovic@x1 /u/s/l/nixnote2 ((v2.1.9))> ./appdir/usr/bin/nixnote2
INFO  2023-07-03 11:38:57.792 src/utilities/crossmemorymapper.cpp:62 Shared memory segment allocated, instance key: "foo"
INFO  2023-07-03 11:38:57.793 src/main.cpp:313 NixNote 2.1.9-f9cbad25, build at Jul  3 2023 at 11:15:34, with Qt 5.15.10 running on 5.15.10
INFO  2023-07-03 11:38:57.793 src/main.cpp:316 To get more detailed startup logging use --logLevel=1
QPainter::setBackgroundMode: Painter not active
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QThread: Destroyed while thread is still running
fish: Job 1, './appdir/usr/bin/nixnote2' terminated by signal SIGABRT (Abort)
ludovic@x1 /u/s/l/nixnote2 ((v2.1.9)) [SIGABRT]>

When I run it using the bash shell, it also tells me it did a coredump:

ludovic@x1 /u/s/l/nixnote2 (develop)> ./appdir/usr/bin/nixnote2
INFO  2023-07-03 12:02:42.647 src/utilities/crossmemorymapper.cpp:62 Shared memory segment allocated, instance key: "foo"
INFO  2023-07-03 12:02:42.647 src/main.cpp:313 NixNote 2.1.10-42acd76f, build at Jul  3 2023 at 12:00:27, with Qt 5.15.10 running on 5.15.10
INFO  2023-07-03 12:02:42.647 src/main.cpp:316 To get more detailed startup logging use --logLevel=1
QPainter::setBackgroundMode: Painter not active
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QThread: Destroyed while thread is still running
Aborted (core dumped)
ludovic@x1 /u/s/l/nixnote2 (develop)>

Happy to do a debug build or anything else you want me to look at, if you can point me to instructions.

Thanks, Ludovic

boo-yee commented 1 year ago

Are your auto sync options enabled? If so, you could try to disable all the options about auto sync temprarily, and see if it happens still.

ludovicaelbrecht commented 1 year ago

I had auto sync on startup & shutdown & every 15 mins enabled. (But those were also enabled on 2.1.8, when it exited cleanly).

I've disabled all 3 of those auto sync settings, and the issue is still there.

This is the output I get now:

ludovic@x1 /u/s/l/nixnote2 (develop)> ./appdir/usr/bin/nixnote2
INFO  2023-07-31 14:44:45.457 src/utilities/crossmemorymapper.cpp:62 Shared memory segment allocated, instance key: "foo"
INFO  2023-07-31 14:44:45.458 src/main.cpp:313 NixNote 2.1.10-42acd76f, build at Jul  3 2023 at 12:00:27, with Qt 5.15.10 running on 5.15.10
INFO  2023-07-31 14:44:45.458 src/main.cpp:316 To get more detailed startup logging use --logLevel=1
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
QThread: Destroyed while thread is still running
fish: Job 1, './appdir/usr/bin/nixnote2' terminated by signal SIGABRT (Abort)

The only message that no longer appears is this one: QPainter::setBackgroundMode: Painter not active

boo-yee commented 1 year ago

You could run nixnote with --logLevel=1, and see what happens.

ps: I noticed that your shared memory segment key is 'foo', instead of a random string, did you do any changes and some of them may change the exiting process of nixnote?

ludovicaelbrecht commented 1 year ago

Hi boo-yee

Thanks for your help.

When running the develop branch with "--logLevel=1", here's the output I get when all auto syncs are disabled and exiting through Ctrl+Q:


DEBUG 2023-08-01 13:07:46.304 src/nixnote.cpp:1153 quitNixNote
DEBUG 2023-08-01 13:07:46.304 src/nixnote.cpp:1313 closeEvent
DEBUG 2023-08-01 13:07:46.304 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-01 13:07:46.304 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-01 13:07:46.304 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-01 13:07:46.305 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-01 13:07:46.324 src/nixnote.cpp:1302 saveOnExit: Closing threads
DEBUG 2023-08-01 13:07:46.324 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-01 13:07:46.325 src/nixnote.cpp:1350 closeEvent: quitting
DEBUG 2023-08-01 13:07:46.340 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-01 13:07:46.341 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-01 13:07:46.341 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-01 13:07:46.341 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-01 13:07:46.358 src/nixnote.cpp:1302 saveOnExit: Closing threads
DEBUG 2023-08-01 13:07:46.358 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-01 13:07:46.358 src/utilities/crossmemorymapper.cpp:109 Shared memory segment detach, instance key: "foo", result: true
DEBUG 2023-08-01 13:07:46.359 src/main.cpp:380 main: deleting NixNote instance
QThread: Destroyed while thread is still running
fish: Job 1, './appdir/usr/bin/nixnote2  --lo…' terminated by signal SIGABRT (Abort)```

Regarding the instance key: no I didn't change anything in the codebase; I just obscured the key in my posts since I didn't know whether this was a nixnote key or an actual Evernote API key. I assumed it was nothing but erred on the side of caution.
boo-yee commented 1 year ago

If so, then in NixNote::saveOnExit(), comment out from line 1302 to 1304, like this:

    //QLOG_DEBUG() << "saveOnExit: Closing threads";
    //indexThread.quit();
    //counterThread.quit();

(or you can apply the patch I upload below) and build again. I tested about 10 times, and found no core dump under bash. You could have a try and see if it can exit normally.

nixnote.patch

ludovicaelbrecht commented 1 year ago

Here's the output I get with the patch applied:

DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1153 quitNixNote
DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1313 closeEvent
DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-02 12:25:28.373 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-02 12:25:28.387 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-02 12:25:28.388 src/nixnote.cpp:1350 closeEvent: quitting
DEBUG 2023-08-02 12:25:28.396 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-02 12:25:28.396 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-02 12:25:28.396 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-02 12:25:28.396 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-02 12:25:28.412 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-02 12:25:28.412 src/utilities/crossmemorymapper.cpp:109 Shared memory segment detach, instance key: "foo", result: true
DEBUG 2023-08-02 12:25:28.412 src/main.cpp:380 main: deleting NixNote instance
QThread: Destroyed while thread is still running
fish: Job 1, './appdir/usr/bin/nixnote2  --lo…' terminated by signal SIGABRT (Abort)

To be complete, it's ~the same when running in bash:

DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1153 quitNixNote
DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1313 closeEvent
DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-02 12:27:26.314 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-02 12:27:26.334 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-02 12:27:26.335 src/nixnote.cpp:1350 closeEvent: quitting
DEBUG 2023-08-02 12:27:26.342 src/nixnote.cpp:1177 saveOnExit()
DEBUG 2023-08-02 12:27:26.342 src/nixnote.cpp:1179 saveOnExit: Saving contents
DEBUG 2023-08-02 12:27:26.342 src/nixnote.cpp:1182 saveOnExit: Shutting down threads
DEBUG 2023-08-02 12:27:26.342 src/nixnote.cpp:1192 Saving window states
DEBUG 2023-08-02 12:27:26.355 src/nixnote.cpp:1306 Exiting saveOnExit()
DEBUG 2023-08-02 12:27:26.355 src/utilities/crossmemorymapper.cpp:109 Shared memory segment detach, instance key: "foo", result: true
DEBUG 2023-08-02 12:27:26.355 src/main.cpp:380 main: deleting NixNote instance
QThread: Destroyed while thread is still running
Aborted (core dumped)
boo-yee commented 1 year ago

If so, it should be syncThread, indexThread, counterThread or browserThread.

Apply this new patch, and try again please. It may work this time.

nixnote.patch

ludovicaelbrecht commented 1 year ago

Thanks for all your help.

No SIGABRT this time:

DEBUG 2023-08-02 14:55:07.382 src/nixnote.cpp:1156 quitNixNote
DEBUG 2023-08-02 14:55:07.382 src/nixnote.cpp:1316 closeEvent
DEBUG 2023-08-02 14:55:07.382 src/nixnote.cpp:1180 saveOnExit()
DEBUG 2023-08-02 14:55:07.382 src/nixnote.cpp:1182 saveOnExit: Saving contents
DEBUG 2023-08-02 14:55:07.382 src/nixnote.cpp:1185 saveOnExit: Shutting down threads
DEBUG 2023-08-02 14:55:07.383 src/nixnote.cpp:1195 Saving window states
DEBUG 2023-08-02 14:55:07.404 src/nixnote.cpp:1309 Exiting saveOnExit()
DEBUG 2023-08-02 14:55:07.405 src/nixnote.cpp:1353 closeEvent: quitting
DEBUG 2023-08-02 14:55:07.411 src/nixnote.cpp:1180 saveOnExit()
DEBUG 2023-08-02 14:55:07.411 src/nixnote.cpp:1182 saveOnExit: Saving contents
DEBUG 2023-08-02 14:55:07.411 src/nixnote.cpp:1185 saveOnExit: Shutting down threads
DEBUG 2023-08-02 14:55:07.412 src/nixnote.cpp:1195 Saving window states
DEBUG 2023-08-02 14:55:07.424 src/nixnote.cpp:1309 Exiting saveOnExit()
DEBUG 2023-08-02 14:55:07.425 src/utilities/crossmemorymapper.cpp:109 Shared memory segment detach, instance key: "foo", result: true
DEBUG 2023-08-02 14:55:07.425 src/main.cpp:380 main: deleting NixNote instance
DEBUG 2023-08-02 14:55:07.425 src/nixnote.cpp:250 !syncThread.isFinished()
DEBUG 2023-08-02 14:55:07.425 src/nixnote.cpp:252 !indexThread.isFinished()
DEBUG 2023-08-02 14:55:07.425 src/nixnote.cpp:254 !counterThread.isFinished()
DEBUG 2023-08-02 14:55:07.426 src/gui/nbrowserwindow.cpp:309 ~NBrowserWindow()
DEBUG 2023-08-02 14:55:07.426 src/gui/nbrowserwindow.cpp:311 quit()
DEBUG 2023-08-02 14:55:07.426 src/gui/nbrowserwindow.cpp:313 isIdle()
DEBUG 2023-08-02 14:55:07.426 src/gui/nbrowserwindow.cpp:315 isFinished()
DEBUG 2023-08-02 14:55:07.426 src/gui/nbrowserwindow.cpp:319 delete thread()
DEBUG 2023-08-02 14:55:07.428 src/gui/nbrowserwindow.cpp:360 ~NBrowserWindow() finished
DEBUG 2023-08-02 14:55:07.432 src/main.cpp:382 main: quitting application instance
DEBUG 2023-08-02 14:55:07.432 src/main.cpp:384 main: deleting application instance
INFO  2023-08-02 14:55:07.447 src/main.cpp:386 main: Exit: retcode=0

(FYI I did have to change while (!browserThread.isFinished()); in the patch to while (!browserThread->isFinished()); for it to compile)

boo-yee commented 1 year ago

Thanks for all your help.

No SIGABRT this time:

That's OK. I'll create a pr for this issue later.

(FYI I did have to change while (!browserThread.isFinished()); in the patch to while (!browserThread->isFinished()); for it to compile)

I forgot to update the patch. My bad.

ludovicaelbrecht commented 1 year ago

Thanks for fixing it, much appreciated.

boo-yee commented 1 year ago

You contributed too. Thank both of us.

prahal commented 11 months ago

@robert7 should I close this bug report or do you want to wait for the fix to reach the master branch? You already merged the PR to the develop branch.

robert7 commented 11 months ago

I just merged develop to master

prahal commented 7 months ago

This issue should be closed. The fix from PR #209 was merged to master.