Ok, a new snapshot of valgrind is out, which finds new problems. I won't look further at this problem (threads are a non-expertise area for me), so if someone has free time to identify/fix the problem, be my guest.
Doing tests in tlib/modules/testsuite (319 tests) test 314, line 732 sched status:
Thread 1: status = WaitCV, associated_mx = 0x8338630, associated_cv = 0x4214F98C ==17679== at 0x4028CE47: pthread_cond_wait (vg_libpthread.c:1095) ==17679== by 0x815E4C4: f_thread_create (/home/nilsson/Pike/7.5/src/threads.c:937) ==17679== by 0x808079E: low_mega_apply (/home/nilsson/Pike/7.5/src/apply_low.h:210) ==17679== by 0x8082B49: mega_apply (/home/nilsson/Pike/7.5/src/interpret.c:1844)
==17679== Warning: pthread scheduler exited due to deadlock