This is another example of why pthread_cancel
is dangerous and should not be ab/used. I've seen this happen in various scenarios when this function is called. There is no guarantee that all hell won't break loose.
Good background reading: https://lwn.net/Articles/683118/
Stack frames 1-21 consolidated for brevity:
[2024-04-09 13:35:36.546] DEBUG[3194062]: module.c:1595 unload_modules_helper: Skipping unload of mod_mail.so with use count 5 on pass 1
[2024-04-09 13:35:36.546] DEBUG[3194062]: module.c:1603 unload_modules_helper: Attempting to unload mod_mail_trash.so
corrupted double-linked list
Aborted (core dumped)
Thread 1 (Thread 0x7fda8a3ab9c0 (LWP 3194062)):
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1 0x00007fda8aea9d9f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 0x00007fda8ae5af32 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007fda8ae45472 in __GI_abort () at ./stdlib/abort.c:79
#4 0x00007fda8ae9e340 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7fda8afb8459 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#5 0x00007fda8aeb36ba in malloc_printerr (str=str@entry=0x7fda8afb605d "corrupted double-linked list") at ./malloc/malloc.c:5660
#6 0x00007fda8aeb3f64 in unlink_chunk (p=p@entry=0x563d157480f0, av=0x7fda8aff1c60 <main_arena>) at ./malloc/malloc.c:1629
#7 0x00007fda8aeb40bc in malloc_consolidate (av=av@entry=0x7fda8aff1c60 <main_arena>) at ./malloc/malloc.c:4768
#8 0x00007fda8aeb6728 in _int_malloc (av=av@entry=0x7fda8aff1c60 <main_arena>, bytes=bytes@entry=1230) at ./malloc/malloc.c:3961
#9 0x00007fda8aeb85f2 in __libc_calloc (n=<optimized out>, elem_size=<optimized out>) at ./malloc/malloc.c:3674
#10 0x00007fda8b843aea in calloc (b=1, a=<optimized out>) at ../include/rtld-malloc.h:44
#11 _dl_new_object (realname=realname@entry=0x563d15704890 "/lib/x86_64-linux-gnu/libgcc_s.so.1", libname=libname@entry=0x7fda8afb7e09 "libgcc_s.so.1", type=type@entry=2, loader=loader@entry=0x0, mode=mode@entry=-1879048190, nsid=nsid@entry=0) at ./elf/dl-object.c:92
#12 0x00007fda8b83f51f in _dl_map_object_from_fd (name=name@entry=0x7fda8afb7e09 "libgcc_s.so.1", origname=origname@entry=0x0, fd=23, fbp=fbp@entry=0x7fff50c1bc00, realname=0x563d15704890 "/lib/x86_64-linux-gnu/libgcc_s.so.1", loader=loader@entry=0x0, l_type=<optimized out>, mode=<optimized out>, stack_endp=<optimized out>, nsid=<optimized out>) at ./elf/dl-load.c:1063
#13 0x00007fda8b840ef5 in _dl_map_object (loader=<optimized out>, loader@entry=0x7fda8b570f80, name=name@entry=0x7fda8afb7e09 "libgcc_s.so.1", type=type@entry=2, trace_mode=trace_mode@entry=0, mode=mode@entry=-1879048190, nsid=<optimized out>) at ./elf/dl-load.c:2272
#14 0x00007fda8b844885 in dl_open_worker_begin (a=a@entry=0x7fff50c1c2b0) at ./elf/dl-open.c:534
#15 0x00007fda8af6de0a in __GI__dl_catch_exception (exception=exception@entry=0x7fff50c1c110, operate=operate@entry=0x7fda8b8447e0 <dl_open_worker_begin>, args=args@entry=0x7fff50c1c2b0) at ./elf/dl-error-skeleton.c:208
#16 0x00007fda8b844046 in dl_open_worker (a=a@entry=0x7fff50c1c2b0) at ./elf/dl-open.c:782
#17 0x00007fda8af6de0a in __GI__dl_catch_exception (exception=exception@entry=0x7fff50c1c290, operate=operate@entry=0x7fda8b844010 <dl_open_worker>, args=args@entry=0x7fff50c1c2b0) at ./elf/dl-error-skeleton.c:208
#18 0x00007fda8b844438 in _dl_open (file=0x7fda8afb7e09 "libgcc_s.so.1", mode=<optimized out>, caller_dlopen=0x7fda8af27489 <__GI___libc_unwind_link_get+73>, nsid=<optimized out>, argc=2, argv=0x7fff50c1c978, env=0x7fff50c1c990) at ./elf/dl-open.c:884
#19 0x00007fda8af6e1dd in do_dlopen (ptr=ptr@entry=0x7fff50c1c500) at ./elf/dl-libc.c:95
#20 0x00007fda8af6de0a in __GI__dl_catch_exception (exception=exception@entry=0x7fff50c1c480, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:208
#21 0x00007fda8af6debf in __GI__dl_catch_error (objname=0x7fff50c1c4c8, errstring=0x7fff50c1c4d0, mallocedp=0x7fff50c1c4c7, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:227
#22 0x00007fda8af6e151 in dlerror_run (operate=operate@entry=0x7fda8af6e1a0 <do_dlopen>, args=args@entry=0x7fff50c1c500) at ./elf/dl-libc.c:45
objname = 0x0
last_errstring = 0x0
malloced = false
result = <optimized out>
#23 0x00007fda8af6e2ef in __libc_dlopen_mode (name=name@entry=0x7fda8afb7e09 "libgcc_s.so.1", mode=mode@entry=-2147483646) at ./elf/dl-libc.c:162
args = {name = 0x7fda8afb7e09 "libgcc_s.so.1", mode = -2147483646, caller_dlopen = 0x7fda8af27489 <__GI___libc_unwind_link_get+73>, map = 0x3f3f3f3f3f3f3f3f}
#24 0x00007fda8af27489 in __GI___libc_unwind_link_get () at ./misc/unwind-link.c:50
local_libgcc_handle = <optimized out>
local = {ptr__Unwind_Backtrace = <optimized out>, ptr__Unwind_ForcedUnwind = <optimized out>, ptr__Unwind_GetCFA = <optimized out>, ptr__Unwind_GetIP = <optimized out>, ptr__Unwind_Resume = <optimized out>, ptr_personality = <optimized out>}
__PRETTY_FUNCTION__ = "__libc_unwind_link_get"
#25 0x00007fda8aea66aa in __pthread_cancel (th=th@entry=140575814706880) at ./nptl/pthread_cancel.c:99
unwind_link = <optimized out>
init_sigcancel = 1
result = <optimized out>
oldval = <optimized out>
newval = <optimized out>
#26 0x0000563d14267f4c in bbs_pthread_cancel_kill (thread=140575814706880) at thread.c:251
res = <optimized out>
__func__ = "bbs_pthread_cancel_kill"
#27 0x00007fda8805e5d0 in unload_module () at mod_mail_trash.c:163
__func__ = "unload_module"
__func__ = "unload_module"
#28 unload_module () at mod_mail_trash.c:160
__func__ = "unload_module"
#29 0x0000563d1424d077 in __unload_module (mod=0x563d15720b60) at module.c:807
res = <optimized out>
nodecount = 0
mod = 0x563d15720b60
lastmod = 0x0
passes = 0
skipped = <optimized out>
__func__ = "unload_modules_helper"
mod = <optimized out>
__func__ = "unload_modules"
#30 unload_modules_helper () at module.c:1604
nodecount = 0
mod = 0x563d15720b60
lastmod = 0x0
passes = 0
skipped = <optimized out>
__func__ = "unload_modules_helper"
mod = <optimized out>
__func__ = "unload_modules"
#31 unload_modules () at module.c:1656
mod = <optimized out>
__func__ = "unload_modules"
#32 0x0000563d142309fc in bbs_shutdown () at bbs.c:581
__func__ = "bbs_shutdown"
__func__ = "bbs_shutdown"
#33 bbs_shutdown () at bbs.c:559
__func__ = "bbs_shutdown"
#34 0x0000563d1422aa81 in monitor_sig_flags (unused=<optimized out>) at bbs.c:805
__func__ = "monitor_sig_flags"
__func__ = "main"
#35 main (argc=<optimized out>, argv=<optimized out>) at bbs.c:1055
__func__ = "main"
You must be