C-Blocks
C-Blocks copied to clipboard
Make C::Blocks thread safe
Please see https://github.com/tsee/C-Blocks/tree/tsee/mutex for a partial fix to make C::Blocks threadsafe. The main commit in that branch outlines what I know is missing from it. Other than that, I think it's not a huge hassle.
HTH, Steffen
Fantastic! I've never used pthreads
(I've only done CUDA parallel programming) so I wasn't sure about the incantation. Furthermore, it's not hard to find Windows examples, such as this one:
https://www.codeproject.com/Articles/25569/Cross-Platform-Mutex
As for the test script, I can work it into the test suite by writing a test script that uses Capture::Tiny to get the output and exit code. I have done quite a bit of this, though I seem to recall most of that work was with C::TinyCompiler.
This was the kind of thing I have meant to clean up for some time, but didn't have the inclination to hunt down. Thank you!
Note, mostly to self: see also https://msdn.microsoft.com/en-us/library/windows/desktop/ms686908(v=vs.85).aspx
I've re-pushed the tsee/mutex branch with another commit:
https://github.com/tsee/C-Blocks/commit/b5b7f8350c30d36f27b9fe7d0b9dc65f47e30689
This one adds that the lock gets unlocked even if an exception is thrown.
Now, if you have a minute, please do read the commit message. There's still segfaults, but not directly out of the TCC-is-compiling-stuff code path.
Does the commit message give you any ideas as to what might be getting double-freed or similar? I don't know the C::Blocks code structure well enough to speculate and ran out of code reading time.
--Steffen