The following console program deadlocks for me on macOS 10.14 almost every time:
#include <JuceHeader.h>
static void makeImages()
{
for (int i = 0; i < 10000; ++i)
{
juce::Image img (juce::Image::PixelFormat::RGB, 300, 300, false);
juce::Graphics g (img);
g.setColour (juce::Colours::black);
g.fillAll();
}
}
int main (int argc, char* argv[])
{
juce::WaitableEvent event;
juce::Thread::launch ([&event] {
makeImages();
event.signal();
});
makeImages();
event.wait();
return 0;
}
It seems the culprit is Typeface::findTypefaceFor. If I wrap the top part of the function (the part protected by a ScopedReadLock) in a {} scope block, the deadlock goes away, but I don’t understand why. Is this some kind of bug in the interaction between a ScopedReadLock and a ScopedWriteLock?
