When the first thread of multimedia/mpv exits after having played a video with the "gpu" (default) output, the programs receives a SIGSEV when it tries to execute one of its destructor:
void _rthread_tls_destructors(pthread_t thread) { [...] for (i = 0; i < PTHREAD_DESTRUCTOR_ITERATIONS; i++) { for (rs = thread->local_storage; rs; rs = rs->next) { if (!rs->data) continue; if (rkeys[rs->keyid].destructor) { void (*destructor)(void *) = rkeys[rs->keyid].destructor; void *data = rs->data; rs->data = NULL; _spinunlock(&rkeyslock); destructor(data); <-- HERE _spinlock(&rkeyslock); } } } [...] } This doesn't happen with other outputs and I haven't checked/don't know which piece of code in the "gpu" output calls pthread_key_create(). Full backtrace below. $ mpv *.mp4 (+) Video --vid=1 (*) (h264 640x352 30.288fps) (+) Audio --aid=1 (*) (aac 2ch 48000Hz) libEGL warning: DRI3: Screen seems not DRI3 capable AO: [sdl] 48000Hz stereo 2ch s32 VO: [gpu] 640x352 yuv420p AV: 00:01:38 / 00:01:38 (100%) A-V: 0.000 Exiting... (End of file) pthread_mutex_destroy on mutex with waiters! Segmentation fault (core dumped) mpi@oliva $ egdb /usr/local/bin/mpv *.core GNU gdb (GDB) 7.12.1 Copyright (C) 2017 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-unknown-openbsd6.8". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://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 /usr/local/bin/mpv...Reading symbols from /usr/local/bin/.d ebug/mpv.dbg...done. done. [New process 566589] [New process 131102] [New process 552326] [New process 162644] Core was generated by `mpv'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000009b1220dfa70 in ?? () [Current thread is 1 (process 566589)] (gdb) thr apply all bt Thread 4 (process 162644): #0 futex () at /tmp/-:3 #1 0x000009b140ca37b5 in _twait (p=0x9b1417da640, val=1, clockid=0, abs=0x0) at /usr/src/lib/libc/thread/synch.h:34 #2 _rthread_cond_timedwait (cond=0x9b1417da640, mutexp=0x9b0adcb19c8, abs=0x0) at /usr/src/lib/libc/thread/rthread_cond.c:106 #3 0x000009aea3812d5c in worker_thread (arg=0x9b0adcb19c0) at ../mpv-0.32.0/misc/thread_pool.c:80 #4 0x000009b19f5a60c1 in _rthread_start (v=<optimized out>) at /usr/src/lib/librthread/rthread.c:96 #5 0x000009b140c9d7f8 in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:77 #6 0x0000000000000000 in ?? () Thread 3 (process 552326): #0 _thread_sys_poll () at /tmp/-:3 #1 0x000009b140c659fe in _libc_poll_cancel (fds=0x9b183f0a630, nfds=2, timeout=-1) at /usr/src/lib/libc/sys/w_poll.c:27 #2 0x000009aea38b1f11 in terminal_thread (ptr=<optimized out>) at ../mpv-0.32.0/osdep/terminal-unix.c:395 #3 0x000009b19f5a60c1 in _rthread_start (v=<optimized out>) at /usr/src/lib/librthread/rthread.c:96 #4 0x000009b140c9d7f8 in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:77 #5 0x0000000000000000 in ?? () Thread 2 (process 131102): #0 futex () at /tmp/-:3 #1 0x000009b19f5a39a4 in _twait (p=0x9b14dbd5648, val=<error reading variable: Cannot access memory at address 0x0>, clockid=<error reading variable: Cannot access memory at address 0x0>, abs=0x0) at /usr/src/lib/librthread/synch.h:41 #2 _sem_wait (sem=0x9b14dbd5640, can_eintr=0, abstime=0x0, delayed_cancel=0x9b140cac500 <_initial_thread+200>) at /usr/src/lib/librthread/rthread_sem.c:76 #3 0x000009b19f5a5bc7 in pthread_join (thread=0x9b14dbd5640, retval=0x0) at /usr/src/lib/librthread/rthread.c:304 #4 0x000009aea389fecf in vo_destroy (vo=0x9b15860cc40) at ../mpv-0.32.0/video/out/vo.c:380 #5 0x000009aea3852e5c in uninit_video_out (mpctx=0x9b126f8b840) at ../mpv-0.32.0/player/video.c:130 #6 0x000009aea384a037 in mp_destroy (mpctx=0x9b126f8b840) at ../mpv-0.32.0/player/main.c:167 #7 0x000009aea384ace4 in mpv_main (argc=<optimized out>, argv=<optimized out>) at ../mpv-0.32.0/player/main.c:490 #8 0x000009aea37b99f1 in ___start () #9 0x0000000000000000 in ?? () Thread 1 (process 566589): #0 0x000009b1220dfa70 in ?? () #1 0x000009b140c85075 in _rthread_tls_destructors (thread=0x9b14dbd5640) at /usr/src/lib/libc/thread/rthread_tls.c:182 #2 0x000009b140c3db93 in _libc_pthread_exit (retval=<optimized out>) at /usr/src/lib/libc/thread/rthread.c:150 #3 0x000009b19f5a60c9 in _rthread_start (v=<optimized out>) at /usr/src/lib/librthread/rthread.c:97 #4 0x000009b140c9d7f8 in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:77 #5 0x0000000000000000 in ?? ()