[LV2] Is state:threadSafeRestore default ?

Sven Jaehnichen sjaehn at jahnichen.de
Tue Dec 8 13:06:06 PST 2020


Hi,

I'm confused about a bug I observed in the DSP of some of my plugins. To 
be more precise: all my plugins with a sample file chooser (B.Jumblr, 
B.Harvestr, and B.Oops) and only if a state is loaded (e.g., by loading 
a preset) during playback. Hosts are jalv or ardour.

These plugins free old samples and instantiate new samples in the same 
way as eg-sampler from the LV2 book. state:threadSafeRestore is NOT 
explicitly supported by the plugin. Thus, I expected that audio 
processing (run()) is interrupted by the host during state::restore(). 
(see http://lv2plug.in/ns/ext/state#threadSafeRestore ).

However, if I unload a sample (delete sample; sample = nullptr;) in the 
restore() function, I may get a nullptr deref crash on access to *sample 
in run() although checked for if (sample) just before:

https://github.com/sjaehn/BOops/blob/f6e5e1ef6259978961cd76b4c237ec44a137322f/src/BOops.cpp#L1057

For me it looks like a race condition that shouldn't occur. I thought 
only if state:threadSafeRestore is supported, then state::restore() may 
run in parallel to run(). And if not supported, restore() is executed 
after run(). Isn't it? Did I oversee sth.?

OK, i can also make my restore() function thread safe. Not that problem. 
But what about eg-sampler? Did somebody observe similar problems there?

Thanks in advance
Sven



More information about the Devel mailing list