Ardour3 stops when loading a session with plugin

Look at the contrast with multithread safety in X Window vs Windows GDI. The X Window folks said “we consider multithreaded to be the less common case - our library has no thread synchronization at all but has been designed so that the caller can add locking if and when necessary”. The Windows folks said “we consider multithreaded to be the common case, so we’ve built locking into the libraries, and it cannot be removed or left unused”.

The Windows guys had a solid reason for this choice: they have pushed threads as the basic task primitive for years, because processes were so heavyweight on that platform. But in general, I prefer the approach that the X Window folks took, which is also shared by the libfftw folks as well: make it possible for the app to lock if it needs to, but don’t add the overhead if it isn’t necessary.

The problem with the plugin model is that the host has a very hard time knowing if it is actually necessary to add locks. The host basically has no idea what the plugin code will do, and so cannot take any steps to deal with issues like this.

@Paul: This kind of belongs in its own thread (no pun intended…) I’m sorry but I think your argument is completely flawed - fundamentally if a library is threadsafe, and surely multi-threaded is now likely to be the more common case, then that should be entirely transparent to the user of the library - or perhaps if necessary, there should be some well documented rules.
(For what its worth, I’m currently working with GUI code in XLib on linux, CoreGraphics on Mac, and GDI on Windows - two out of those three ‘just work’ almost without even thinking about threads - the other one… well I’ll leave you guess which one doesn’t)

The problem with the plugin model is that the host has a very hard time knowing if it is actually necessary to add locks. The host basically has no idea what the plugin code will do, and so cannot take any steps to deal with issues like this.

Which is exactly why the host shouldn’t try (or have to) do anything to deal with this at all. If it seems necessary that the host should, then either the host is doing something which is just fundamentally crazy, or the plugin is broken.