Open fidergo-stephane-gourichon opened 7 years ago
Gdb stacktrace, compiled from commit 1334329 "Document regular expressions".
(gdb) run
Starting program: .../xdotool search --onlyvisible --class . behave %@ focus getactivewindow
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGABRT, Aborted.
0x00007ffff6feb428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: Aucun fichier ou dossier de ce type.
(gdb) bt
#0 0x00007ffff6feb428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff6fed02a in __GI_abort () at abort.c:89
#2 0x00007ffff702d7ea in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7ffff7146e98 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff703637a in malloc_printerr (ar_ptr=<optimized out>, ptr=<optimized out>, str=0x7ffff7146fa8 "double free or corruption (out)", action=3) at malloc.c:5006
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3867
#5 0x00007ffff703a53c in __GI___libc_free (mem=<optimized out>) at malloc.c:2968
#6 0x0000000000402c6a in window_save (context=context@entry=0x7fffffffd3b0, window=33594520) at xdotool.c:62
#7 0x0000000000407815 in cmd_getactivewindow (context=0x7fffffffd3b0) at cmd_getactivewindow.c:41
#8 0x000000000040306d in context_execute (context=context@entry=0x7fffffffd3b0) at xdotool.c:587
#9 0x0000000000408d3f in cmd_behave (context=0x7fffffffd550) at cmd_behave.c:145
#10 0x000000000040306d in context_execute (context=context@entry=0x7fffffffd550) at xdotool.c:587
#11 0x0000000000403a7e in args_main (argv=<optimized out>, argc=8) at xdotool.c:560
#12 xdotool_main (argc=9, argv=0x7fffffffd748) at xdotool.c:318
#13 0x00007ffff6fd6830 in __libc_start_main (main=0x402a70 <main>, argc=9, argv=0x7fffffffd748, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd738) at ../csu/libc-start.c:291
#14 0x0000000000402aa9 in _start ()
(gdb)
I've got a similar issue (Ubuntu 19.04). Did you manage to fix this?
I think I have fixed it. Try this:
diff --git a/cmd_behave.c b/cmd_behave.c
index 6ddead0..748acb0 100644
--- a/cmd_behave.c
+++ b/cmd_behave.c
@@ -109,7 +109,10 @@ int cmd_behave(context_t *context) {
// Copy context
context_t tmpcontext = *context;
- tmpcontext.nwindows = 1;
+ /* The appropriate window will be saved with window_save. */
+ tmpcontext.windows = NULL;
+ tmpcontext.nwindows = 0;
+
Window hover; /* for LeaveNotify */
switch (e.type) {
case LeaveNotify:
@@ -132,16 +135,16 @@ int cmd_behave(context_t *context) {
/* fall through */
case EnterNotify:
- tmpcontext.windows = &(e.xcrossing.window);
+ window_save(&tmpcontext, e.xcrossing.window);
ret = context_execute(&tmpcontext);
break;
case FocusIn:
case FocusOut:
- tmpcontext.windows = &(e.xfocus.window);
+ window_save(&tmpcontext, e.xfocus.window);
ret = context_execute(&tmpcontext);
break;
case ButtonRelease:
- tmpcontext.windows = &(e.xbutton.window);
+ window_save(&tmpcontext, e.xbutton.window);
ret = context_execute(&tmpcontext);
break;
default:
@FascinatedBox's patch seems to work for me at least.
Context
This command:
Expected
Outputs ID of newly focused window any time focus changes.
Observed
Crashes with:
Observed on Ubuntu 16.04 AMD64.
Comparison
Replacing
getactivewindow
withgetwindowpid
, it no longer crashes:It outputs duplicate ids but that's another, more minor, issue.