Loading the attached patch into libpd/samples/c/pdtest_thread compiled with PDINSTANCE and PDTHREADS leads to a crash.
test_readsf.zip

(a valid sound.wav exists in the directory; loading the patch with regular Pd doesn't crash).
Here is the backtrace of gdb:
(...)
[New Thread 0x7fffde7fc700 (LWP 32680)]
print: open ./sound.wav
[New Thread 0x7ffff6782700 (LWP 32681)]
(...)
Thread 14 "pdtest_thread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffde7fc700 (LWP 32680)]
0x00007ffff7b38f32 in open_via_path (dir=0x7fffe8013010 ".", name=0x7fffd4018450 "./sound.wav", ext=0x7ffff7b8fb46 "", dirresult=0x7fffde7fb9f0 "", nameresult=0x7fffde7fb9e8, size=1000, bin=1)
at pure-data/src/s_path.c:404
404 size, bin, STUFF->st_searchpath));
(gdb) bt
#0 0x00007ffff7b38f32 in open_via_path (dir=0x7fffe8013010 ".", name=0x7fffd4018450 "./sound.wav", ext=0x7ffff7b8fb46 "", dirresult=0x7fffde7fb9f0 "", nameresult=0x7fffde7fb9e8, size=1000, bin=1)
at pure-data/src/s_path.c:404
#1 0x00007ffff7ab70c2 in open_soundfile (dirname=0x7fffe8013010 ".", filename=0x7fffd4018450 "./sound.wav", p_info=0x7fffde7fbe50, skipframes=0) at pure-data/src/d_soundfile.c:484
#2 0x00007ffff7abb47a in readsf_child_main (zz=0x7fffd4018760) at pure-data/src/d_soundfile.c:1825
#3 0x00007ffff78626ba in start_thread (arg=0x7fffde7fc700) at pthread_create.c:333
#4 0x00007ffff75984dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
The problem could be somewhere around STUFF->st_searchpath; it looks like the pdinstance context is not well defined inside of the child thread of readsf. I guess it's the same for writesf (didn't check yet).
I wondered if this had to be reported into the libpd's issues; I more think the fix will be here.
Loading the attached patch into
libpd/samples/c/pdtest_threadcompiled withPDINSTANCEandPDTHREADSleads to a crash.test_readsf.zip

(a valid
sound.wavexists in the directory; loading the patch with regular Pd doesn't crash).Here is the backtrace of gdb:
The problem could be somewhere around
STUFF->st_searchpath; it looks like the pdinstance context is not well defined inside of the child thread of readsf. I guess it's the same for writesf (didn't check yet).I wondered if this had to be reported into the libpd's issues; I more think the fix will be here.