dsalt / devilspie2

Devilspie2 is a window matching utility, allowing the user to perform scripted actions on windows as they are opened and closed.
GNU General Public License v3.0
132 stars 15 forks source link

Aborted at function fopen() #15

Closed muello closed 1 year ago

muello commented 1 year ago

Maybe someone here would be kind enough to take a look at this https://savannah.nongnu.org/bugs/index.php?62848

Pointers would be much appreciated!

dsalt commented 1 year ago

I've had a look and I can't trigger the problem here. A backtrace (at least) is needed to assist with this.

muello commented 1 year ago

Thanks for taking a look. How do I get a backtrace? I've checked the readme, but don't know where else to look to work out what you mean.

dsalt commented 1 year ago

You'll need gdb and, ideally, the debug info for glibc (in Debian and derivatives, that's libc6-dbg). Compiling devilspie2 with debug info also helps.

$ make clean
$ make DEBUG=1
$ gdb bin/devilspie2
…
(gdb) run

Now do what's needed to trigger the problem.

(gdb) bt

What follows that command is what you want (excluding any paging prompts).

Also, which version of lua are you using? I'm presently using 5.3.6.

muello commented 1 year ago

Ok, thanks, I follow you so far.

I'm not sure how I installed devilspie2 last time, but make clean and make debug=1 both complained this time about missing dependencies.

Note: liblua5.3-0-dev is not in my repos – debian-bullseye and bullseye backports. liblua5.3-dev is available, so I installed it. I also needed gettext (for msgfmt, required by make debug=1).

If at this point I try $ gdb bin/devilspie2 then I get

Reading symbols from bin/devilspie2...
(No debugging symbols found in bin/devilspie2)
(gdb) run
Starting program: /[my/homedir]/.local/git-repos/devilspie2/bin/devilspie2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff12ea700 (LWP 148849)]
[New Thread 0x7ffff0ae9700 (LWP 148850)]
[Detaching after vfork from child process 148851]
[Detaching after vfork from child process 148853]
[Detaching after vfork from child process 148855]
[Detaching after vfork from child process 148865]

Creating the window in another terminal leads to the addition of the line:

Aborted at function fopen()

However, I'm not returned to a gdb prompt. I can type bt or whatever I like, but gdb is unresponsive, so I'm not sure what to do, other than ctrl-C'ing out. Ideas?

As for lua versions:

$ apt search "^lua|liblua" | grep installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

liblua5.1-0/oldstable,now 5.1.5-8.1+b3 amd64 [installed,automatic]
liblua5.2-0/oldstable,now 5.2.4-1.1+b3 amd64 [installed,automatic]
liblua5.3-0/oldstable,now 5.3.3-1.1+b1 amd64 [installed,automatic]
liblua5.3-dev/oldstable,now 5.3.3-1.1+b1 amd64 [installed]
libluajit-5.1-2/oldstable,now 2.1.0~beta3+dfsg-5.3 amd64 [installed,automatic]
libluajit-5.1-common/oldstable,oldstable,now 2.1.0~beta3+dfsg-5.3 all [installed,automatic]
lua-bitop/oldstable,now 1.0.2-5 amd64 [installed,automatic]
lua-expat/oldstable,now 1.3.0-4+b1 amd64 [installed,automatic]
lua-json/oldstable,oldstable,now 1.3.4-2 all [installed,automatic]
lua-lpeg/oldstable,now 1.0.2-1 amd64 [installed,automatic]
lua-luv/oldstable,now 1.36.0-0-1 amd64 [installed,automatic]
lua-socket/oldstable,now 3.0~rc1+git+ac3201d-4 amd64 [installed,automatic]
dsalt commented 1 year ago

You're lacking debug info – use DEBUG, not debug.

Also, it'd help to add break abort before run (answer ‘y’ to the question about making the breakpoint pending) as it'll avoid a few extra stack frames which aren't necessary here from being in the backtrace.

Could you try with set debug threads on before run?

muello commented 1 year ago

Here’s the output I get.

$ make clean
rm -rf obj/config.o obj/devilspie2.o obj/xutils.o obj/script.o obj/script_functions.o obj/error_strings.o bin/devilspie2 Makefile.dep
make -C po clean
make[1]: Entering directory '/[my/homedir]/.local/git-repos/devilspie2/po'
rm -f *.mo
rm -f *~
make[1]: Leaving directory '/[my/homedir]/.local/git-repos/devilspie2/po'
$ make DEBUG=1
cc -MM -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\" src/*.c | sed -e "s/\([A-Za-z0-9+-0._&+-]*:\)/\obj\/\1/g" > Makefile.dep
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/config.c -o obj/config.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/devilspie2.c -o obj/devilspie2.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/xutils.c -o obj/xutils.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/inclu
de/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/script.c -o obj/script.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/script_functions.c -o obj/script_functions.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\"  -c src/error_strings.c -o obj/error_strings.o
cc -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG  -Og -g3 -ggdb -pthread -I/usr/include/libwnck-3.0 -I/usr/include/startup-notification-1.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.3 -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"devilspie2\" -DDEVILSPIE2_VERSION=\"0.45\" -Wall -Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2 -D_DEBUG   obj/config.o obj/devilspie2.o obj/xutils.o obj/script.o obj/script_functions.o obj/error_strings.o -o bin/devilspie2 -lX11 -lXinerama -lwnck-3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -llua5.3
make -C po -j1 all
make[1]: Entering directory '/[my/homedir]/.local/git-repos/devilspie2/po'
for po in sv fr pt_BR nl ru fi ja it; \
do msgfmt -v --statistics -c -o t-${po} ${po}.po && mv -f t-${po} ${po}.mo; \
done
sv.po: 35 translated messages.
fr.po: 35 translated messages.
pt_BR.po: 34 translated messages.
nl.po: 35 translated messages.
ru.po: 34 translated messages.
fi.po: 34 translated messages.
ja.po: 35 translated messages.
it.po: 35 translated messages.
make[1]: Leaving directory '/[my/homedir]/.local/git-repos/devilspie2/po'
$  gdb bin/devilspie2
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 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:
<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 bin/devilspie2...
(gdb) break abort
Function "abort" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (abort) pending.
(gdb) set debug threads on
Undefined set debug command: "threads on".  Try "help set debug".
(gdb) run
Starting program: /[my/homedir]/.local/git-repos/devilspie2/bin/devilspie2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff12ea700 (LWP 183054)]
[New Thread 0x7ffff0ae9700 (LWP 183055)]
[Detaching after vfork from child process 183056]
[Detaching after vfork from child process 183058]
[Detaching after vfork from child process 183060]
[Detaching after vfork from child process 183168]
Aborted at function fopen()

Here’s what I get for (gdb) help set debug

Generic command for setting gdb debugging flags.

List of set debug subcommands:

set debug arch -- Set architecture debugging.
set debug auto-load -- Set auto-load verifications debugging.
set debug bfd-cache -- Set bfd cache debugging.
set debug check-physname -- Set cross-checking of "physname" code against demangler.
set debug coff-pe-read -- Set coff PE read debugging.
set debug compile -- Set compile command debugging.
set debug compile-cplus-scopes -- Set debugging of C++ compile scopes.
set debug compile-cplus-types -- Set debugging of C++ compile type conversion.
set debug displaced -- Set displaced stepping debugging.
set debug dwarf-die -- Set debugging of the DWARF DIE reader.
set debug dwarf-line -- Set debugging of the dwarf line reader.
set debug dwarf-read -- Set debugging of the DWARF reader.
set debug entry-values -- Set entry values and tail call frames debugging.
set debug expression -- Set expression debugging.
set debug frame -- Set frame debugging.
set debug index-cache -- Set display of index-cache debug messages.
set debug infrun -- Set inferior debugging.
set debug jit -- Set JIT debugging.
set debug libthread-db -- Set libthread-db debugging.
set debug lin-lwp -- Set debugging of GNU/Linux lwp module.
set debug linux-namespaces -- Set debugging of GNU/Linux namespaces module.
set debug notification -- Set debugging of async remote notification.
set debug observer -- Set observer debugging.
set debug overload -- Set debugging of C++ overloading.
set debug parser -- Set parser debugging.
set debug py-unwind -- Set Python unwinder debugging.
set debug record -- Set debugging of record/replay feature.
set debug remote -- Set debugging of remote protocol.
set debug remote-packet-max-chars -- Set the maximum number of characters to display for each remote packet.
set debug separate-debug-file -- Set printing of separate debug info file search debug.
set debug serial -- Set serial debugging.
set debug skip -- Set whether to print the debug output about skipping files and functions.
set debug stap-expression -- Set SystemTap expression debugging.
set debug symbol-lookup -- Set debugging of symbol lookup.
set debug symfile -- Set debugging of the symfile functions.
set debug symtab-create -- Set debugging of symbol table creation.
set debug target -- Set target debugging.
set debug timestamp -- Set timestamping of debugging messages.
set debug varobj -- Set varobj debugging.
set debug xml -- Set XML parser debugging.

Type "help set debug" followed by set debug subcommand name for full documentation.
Type "apropos word" to search for commands related to "word".
Type "apropos -v word" for full documentation of commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) 
dsalt commented 1 year ago

Right… looks like gdb (in buster) doesn't have that thread debug option, but gdb (in bookworm) does.

Okay, since you're not seeing a gdb prompt after that abort… I've had another look at the original report and I'm (belatedly) thinking that it's not devilspie2 which is aborting.

Perhaps change the xseticon … command to echo xseticon … (i.e. prepend echo) and see what you get.

Perhaps also try this (or update to commit 6e3b1f0a):

diff --git a/src/script_functions.c b/src/script_functions.c
index 7440ffd..d93c0ca 100644
--- a/src/script_functions.c
+++ b/src/script_functions.c
@@ -1696,7 +1696,7 @@ int c_get_window_xid(lua_State *lua)
        WnckWindow *window = get_current_window();
        gulong result = window ? wnck_window_get_xid(window) : 0;

-       lua_pushnumber(lua, result);
+       lua_pushinteger(lua, result);

        return 1;
 }
muello commented 1 year ago

Ok, so in my script I’ve changed

if (get_window_name() == "elpher") then
  os.execute("xseticon -id " .. get_window_xid() .. " /[my/homedir]/.local/share/icons/papirus-dark/128x128/gemini.png");
end

so that the second line reads

  os.execute("echo xseticon -id " .. get_window_xid() .. " /[my/homedir]/.local/share/icons/papirus-dark/128x128/gemini.png");

Running dp2 and triggering the window:

$ devilspie2 -d
Running devilspie2 in debug mode.

Using scripts from folder: /[my/homedir]/.config/devilspie2
------------
List of Lua files handling "window_open" events in folder:
/[my/homedir]/.config/devilspie2/set-icons.lua
List of Lua files handling "window_close" events in folder:
List of Lua files handling "window_focus" events in folder:
List of Lua files handling "window_blur" events in folder:
------------
(...)
Window Name: xfce4-panel
Window Name: kitty
xseticon -id 157286718.0 /[my/homedir]/.local/share/icons/papirus-dark/128x128/gemini.png

Next, I’ve pulled your 6e3b1f0.

Then done a make clean ; make

The old version of my script still leads to the error, while the new one results in the change that the id number loses its trailing .0: "xseticon -id 155189566 ...".

dsalt commented 1 year ago

So no error with the echo in place, if I'm reading that right – which suggests that it's xseticon which is falling over.

muello commented 1 year ago

Yes, you're right. Manually calling xseticon -id 167772478 /[my/homedir]/.local/share/icons/papirus-dark/128x128/gemini.png produces the error. Thanks for all the help!