Skip to content

Fix segmentation faults when interrupting a thread while it is exiting

username-removed-1342825 requested to merge spaghettisalat/ecl:develop into develop

Thread cleanup is not protected from happening simultaneously with an interrupt. This can lead to the interrupting code trying to access the already deallocated environment, as can be seen from the attached stack trace:

Thread 4 "ecl" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb65c0b40 (LWP 17481)]
ecl_get_spinlock (the_env=0x0, lock=0x19c) at /home/marius/ecl-git/src/c/threads/queue.d:37
37	  while (!AO_compare_and_swap_full((AO_t*)lock, (AO_t)ECL_NIL,
(gdb) bt
#0  ecl_get_spinlock (the_env=0x0, lock=0x19c) at /home/marius/ecl-git/src/c/threads/queue.d:37
#1  0xb7dacc37 in queue_signal (env=0x0, code=0x80105a00, allocate=allocate@entry=1) at /home/marius/ecl-git/src/c/unixint.d:379
#2  0xb7dad878 in ecl_interrupt_process (process=0x82520f00, function=<optimized out>) at /home/marius/ecl-git/src/c/unixint.d:1012
#3  0xb7dbf0df in mp_interrupt_process (process=0x82520f00, function=0xb7f3a59c <cl_symbols+39676>)
    at /home/marius/ecl-git/src/c/threads/process.d:453

Merge request reports