alexandervdm / gummi

Simple LaTeX editor
https://gummi.app
MIT License
750 stars 95 forks source link

random crash on startup #169

Closed RiedleroD closed 2 years ago

RiedleroD commented 2 years ago

Describe the bug When starting gummi, I'd say there's a 50% chance it crashes with a segfault. Looks like a race condition to me, though I have no idea what could've triggered this. It could've started happening somewhere between a month ago and now, since I don't use latex all that often.

To Reproduce Steps to reproduce the behavior:

  1. start the program (doesn't matter from where, but the CLI gives some output on crash)
  2. if it doesn't immedeately crash, close gummi and go back to step 1.

System:

Other My configuration is not the cause, as it still crashes after deleting it. Maybe it was triggered by an update of some dependency.

witjon commented 2 years ago

I'm able to reproduce.

According to gdb it crashes here https://github.com/alexandervdm/gummi/blob/d75a01cc72f68e31e2c5159066ab2111128f16a4/src/compile/latexmk.c#L44=

If you run it from the console with the --debug option you may spot a line similar to [Info] Typesetter detected: Latexmk �������.

I haven't looked very closely yet. My initial findings are that https://github.com/alexandervdm/gummi/blob/d75a01cc72f68e31e2c5159066ab2111128f16a4/src/external.c#L104= does not give a stable output. I think this schema is pretty outdated https://github.com/alexandervdm/gummi/blob/d75a01cc72f68e31e2c5159066ab2111128f16a4/src/external.c#L155-L156=. Parsing the output of the version sting is very error prone and may break at any time.

EDIT: I just confirmed the behavior change in version 4.77. Debian provides a readable diff in their Git mirror latexmk.pl#L1815-R1960.

FreaxMATE commented 2 years ago

Same for me. Sporadic crashes when a document is being opened from the file manager (caja) and sometimes also from command line.

GDB gebug log:

kunruh@thinkfreax ~ [SIGSEGV]> gdb gummi
GNU gdb (GDB) 11.2
Copyright (C) 2022 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-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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 gummi...
(No debugging symbols found in gummi)
(gdb) r
Starting program: /usr/bin/gummi 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff2394640 (LWP 26547)]
[New Thread 0x7ffff1b93640 (LWP 26548)]
[New Thread 0x7ffff126e640 (LWP 26549)]
[Thread 0x7ffff126e640 (LWP 26549) exited]
[New Thread 0x7ffff126e640 (LWP 26550)]
[New Thread 0x7ffff09ce640 (LWP 26551)]
[Thread 0x7ffff126e640 (LWP 26550) exited]
[Thread 0x7ffff09ce640 (LWP 26551) exited]
[New Thread 0x7ffff09ce640 (LWP 26552)]
[New Thread 0x7ffff126e640 (LWP 26553)]
[Thread 0x7ffff09ce640 (LWP 26552) exited]
[Thread 0x7ffff126e640 (LWP 26553) exited]
[New Thread 0x7ffff126e640 (LWP 26554)]
[Info] Gummi version: 0.8.2
[Info] Configuration file: /home/kunruh/.config/gummi/gummi.ini
[Detaching after fork from child process 26555]
[Info] Texlive 2021 was found installed
[Detaching after fork from child process 26556]
[Info] Typesetter detected: pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021/Arch Linux)
[Detaching after fork from child process 26557]
[Info] Typesetter detected: XeTeX 3.141592653-2.6-0.999993 (TeX Live 2021/Arch Linux)
[Detaching after fork from child process 26558]
[Info] Typesetter detected: This is LuaHBTeX, Version 1.13.2 (TeX Live 2021/Arch Linux)
[Detaching after fork from child process 26559]
[Info] 
Thread 1 "gummi" received signal SIGSEGV, Segmentation fault.
0x00007ffff6fda4bd in __strlen_avx2 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff6fda4bd in __strlen_avx2 () at /usr/lib/libc.so.6
#1  0x00007ffff6ec9071 in __vfprintf_internal () at /usr/lib/libc.so.6
#2  0x00007ffff6ed966c in __vsnprintf_internal () at /usr/lib/libc.so.6
#3  0x000055555557d9d0 in slog ()
#4  0x00005555555693cd in latexmk_init ()
#5  0x000055555557a26f in latex_init ()
#6  0x00005555555651f1 in main ()
(gdb) 

with gummi --debug:

kunruh@thinkfreax ~> gummi --debug
[Info] Gummi version: 0.8.2
[Info] Configuration file: /home/kunruh/.config/gummi/gummi.ini
[Info] Texlive 2021 was found installed
[Info] Typesetter detected: pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021/Arch Linux)
[Info] Typesetter detected: XeTeX 3.141592653-2.6-0.999993 (TeX Live 2021/Arch Linux)
[Info] Typesetter detected: This is LuaHBTeX, Version 1.13.2 (TeX Live 2021/Arch Linux)
[Info] fish: Job 1, 'gummi --debug' terminated by signal SIGSEGV (Address boundary error)
kunruh@thinkfreax ~ [SIGSEGV]> 
alexandervdm commented 2 years ago

Thanks to both of you for your efforts & information. The parsing code hurts to look at. I will make general improvements to the whole procedure sometime this week and release 0.8.3 before Friday.

alexandervdm commented 2 years ago

I wrote some quick code that should fix the immediate issue you are having. The parsing code is pretty terrible in general, but I don't want to put much effort into it at this time as I plan to revamp this element completely for 0.9.0.

More specifically I would like to add custom typesetting commands and maybe integrate a solution like Tectonic.

Thanks to all involved.