Dear all,

I am experiencing a strange bug in Pd 0.55.1.
When I launch Pd, it crashes.
Running it with Valgrind, I got the following message:
==83263== Thread 4:
==83263== Invalid free() / delete / delete[] / realloc()
==83263==    at 0x48461EF: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==83263==    by 0x1D9539: jack_polling_callback (s_audio_jack.c:164)
==83263==    by 0x4A7AECC: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A7AB87: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A97F2F: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4B46731: start_thread (pthread_create.c:447)
==83263==    by 0x4BC10FF: clone (clone.S:100)
==83263==  Address 0x535b180 is 0 bytes inside a block of size 65,536 free'd
==83263==    at 0x48461EF: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==83263==    by 0x1D9522: jack_polling_callback (s_audio_jack.c:160)
==83263==    by 0x4A7AECC: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A7AB87: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A97F2F: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4B46731: start_thread (pthread_create.c:447)
==83263==    by 0x4BC10FF: clone (clone.S:100)
==83263==  Block was alloc'd at
==83263==    at 0x48489F3: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==83263==    by 0x188F16: getbytes (m_memory.c:21)
==83263==    by 0x1D94F8: jack_polling_callback (s_audio_jack.c:115)
==83263==    by 0x4A7AECC: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A7AB87: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4A97F2F: ??? (in /usr/lib/x86_64-linux-gnu/libjack.so.0.1.0)
==83263==    by 0x4B46731: start_thread (pthread_create.c:447)
==83263==    by 0x4BC10FF: clone (clone.S:100)
==83263==

Running it via gdb, I am getting the following message:
Thread 4 "pd" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff74926c0 (LWP 109587)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
warning: 44     ./nptl/pthread_kill.c: No such file or directory

Then, I build Pd tag 0.54.1 commit 0259d003 and everything works fine, while I am getting the same error directly from Pd tag 0.55-0test1 commit 46e3ec2d.

I manage to open Pd in callback mode while avoiding polling.
Here some details about my setup:
Debian 12, Linux kernel 6.10
Jackd2 installed via apt, v 1.9.22
Pd installed via apt, 0.55.1, and then built locally using --enable-debug --enable-jack as flags for the configuration. Source code cloned from git.

I also tried to search (randomly) in my local machine where pthread_kill.c is located, without success. libpthread is in: /usr/lib/x86_64-linux-gnu/ .

I took a look at recent emails and issues on Github but I do not see anything relevant with this issue.

My next step is to compare and study the relevant code (starting from s_audio_jack.c) that differs between 0.54.1 and 0.55.0test1. 

If someone has some ideas, they are appreciated.
Additionally, if useful, I can report an issue on Github. Honestly, I am stuck while understanding if it is an issue on my local machine, such that an issue may be noise on the main repo.

Best regards,
Marco