Subject: bug#18259: 24.3; comint-interrupt-subjob fails to interrupt pthreaded programs

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 04 Dec 2020 12:28:49 +0100

Kari Pahula <[email-masked]> writes:

> Trying to interrupt a debugged program in gud fails.  Pressing C-c C-c
> just displays "C-c C-cQuit" but nothing else happens.  This works in
> Emacs version 23.  It seems to me that Emacs 24 doesn't know how to
> signal stop to programs using pthreads.  The program in question is
> available at https://github.com/kaol/forcelayout
>
> (gdb) r
> Starting program: /home/kaol/src/forcelayout/forcelayout -i 1000 -r world-20140811.json picks-20140812.json world-20140812.json
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> [New Thread 0x7ffff7308700 (LWP 14323)]
> [New Thread 0x7ffff6ab7700 (LWP 14324)]
> [New Thread 0x7ffff6266700 (LWP 14325)]
> [New Thread 0x7ffff5a15700 (LWP 14326)]
> [New Thread 0x7ffff51c4700 (LWP 14327)]
> [New Thread 0x7ffff4973700 (LWP 14328)]
> [New Thread 0x7ffff4122700 (LWP 14329)]
> [New Thread 0x7ffff38d1700 (LWP 14330)]
> [New Thread 0x7fffec645700 (LWP 14331)]
> [Thread 0x7fffec645700 (LWP 14331) exited]
>   C-c C-cQuit
> k
> (gdb) 

(This bug report unfortunately got no response at the time.)

I tried reproducing this bug with Emacs 28 -- by using gdb on Emacs
itself, which also uses pthreads, I think?  This seems to work fine for
me.  Are you still seeing this issue in more recent Emacs versions?

(gdb) r
Starting program: /home/larsi/src/emacs/trunk/src/emacs 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffeb6c8700 (LWP 167374)]
[New Thread 0x7fffeacbd700 (LWP 167375)]
[New Thread 0x7fffea273700 (LWP 167376)]
[Detaching after vfork from child process 167389]
[Detaching after vfork from child process 167390]
  C-c C-c[Thread 0x7fffeacbd700 (LWP 167375) exited]
[Thread 0x7fffeb6c8700 (LWP 167374) exited]
[Thread 0x7fffec5ea5c0 (LWP 167369) exited]
[Inferior 1 (process 167369) exited normally]
(gdb)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no