pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.59k stars 518 forks source link

Segfault when creating a new file #1174

Open madmaxoft opened 4 months ago

madmaxoft commented 4 months ago

I'm using ZBS from current master at 803d3823639c0e3b0163079f427eb223180387c3 on KDE Neon. I've just noticed a segfault in ZBS that is 100%-repeatable on one of my computers, but not on the other (with identical OS and ZBS version):

  1. Open ZBS
  2. Change to a different project folder using toolbar and browsing for the folder
  3. Create a new file via the rclk menu in the Project dock window
  4. ZBS crashes

I've tried running ZBS under gdb with the following:

gdb bin/linux/x64/lua

[... snip ...]

(No debugging symbols found in bin/linux/x64/lua)
(gdb) r src/main.lua
Starting program: /home/xoft/Programs/ZeroBraneStudio/bin/linux/x64/lua src/main.lua
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Detaching after vfork from child process 24605]

[... snip ...]

[Thread 0x7ffff21ff640 (LWP 24758) exited]

(lua:24602): Gtk-WARNING **: 20:30:06.069: Negative content width -8 (allocation 10, extents 9x9) while allocating gadget (node entry, owner GtkEntry)
[Thread 0x7ffff32b7640 (LWP 24759) exited]
[New Thread 0x7ffff32b7640 (LWP 24760)]
[New Thread 0x7ffff21ff640 (LWP 24761)]
[New Thread 0x7fffd8ffd640 (LWP 24762)]
[New Thread 0x7fffd27fc640 (LWP 24763)]
double free or corruption (out)

Thread 1 "lua" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737352601600) at ./nptl/pthread_kill.c:44
Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
44      ./nptl/pthread_kill.c: No such file or directory.

Unfortunately I'm not too familiar with Linux troubleshooting, so I have no idea what to explore next in order to provide more information. Not to mention that I don't think this is exactly ZBS's fault, Lua shouldn't segfault like this, I assume some loaded library is causing this.

pkulchenko commented 4 months ago

Interesting; thank you for the report. Do you also get the crash when you cancel adding the filename (select new file, but then use Esc to cancel)? Does the filename matter in this case or does it happen with any file added?

madmaxoft commented 4 months ago

I don't even get to enter a filename, ZBS crashes within a second or two after displaying the filename edit box.

madmaxoft commented 4 months ago

I think I know what could be causing this.

I have a script that is run by cron that creates a file in the affected project folder, then edits another file, and removes the (previously created) file really quickly (SQLite DB single-row append), it runs every 5 seconds. ZBS seems to catch on the file being created and removed, and that seems to throw it off. The crash doesn't happen in any other project folder, only in this specific one.

pkulchenko commented 4 months ago

Very interesting; can you try setting filetree.showchanges=false in the config and see if it makes any difference?

madmaxoft commented 4 months ago

No more segfaults when this setting is applied.

So I guess we found the reason, but what can be done about it?