I’m working on a Pango extension for PHP and ran into a race condition that occasionally causes a segfault during PHP process shutdown. From my analysis so far, I see that the issue is related to the asynchronous worker thread started in pangofc-fontmap.c.
Currently I use usleep(50000) as a workaround to wait for the thread, but this is unreliable. Is there a way to:
Synchronously wait for the thread to complete
Test whether the thread has terminated
Properly coordinate shutdown to avoid the race condition
Any guidance on the proper cleanup sequence would be appreciated.
I work against Pango 1.56.3 on Ubuntu 25.10 in a docker container.
It is my understanding that the shutdown function adds FC_END to the async queue of the background thread but does not actually wait for the thread being terminated.
Do you happen to know if that is correct?
I tried to use this function but still got the race condition and hence segfaults.