I’ve spent a few days playing with embedding Julia into C++ signal processing code. My aim is to be able to quickly write prototype code in Julia that is then executed in a real-time audio host.
The problem that I have now encountered is that the real-time audio rendering callback runs in a different thread than the other setup code. So after I have initialized everything that I require for interfacing with the julia code and have disabled garbage collection, I receive the actual real-time thread callback that I’m relaying to julia, which crashes with an access violation in jl_enter_handler.
It turns out that julia tries to access information from the thread local storage. With the audio real-time thread unknown to julia, it does not find an associate local storage and the walks right into accessing uninitialised memory.
Unfortunately, I cannot move my initialisation code to the real-time thread, so I’m not sure how I can proceed. Is there any way to inform julia of the existence of the other thread so that it can allocate the TLS properly? Are there any other options that would allow me to call julia functions from this thread?