As far as I can say, this MR looks good and it seems to fix my problem.
It's not the proper solution, as Rémi said. The proper solution would be, I think, to always use pthread's stack for syscalls and unwind the stack when exiting from a thread. We could probably use pthread's cleanup mechanism ourselves to unwind the Win32 frames, I guess.
Still, that feels a step in the right direction.