C-Blocks icon indicating copy to clipboard operation
C-Blocks copied to clipboard

Make C::Blocks thread safe

Open tsee opened this issue 8 years ago • 3 comments

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

tsee avatar Jan 02 '17 16:01 tsee

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!

run4flat avatar Jan 03 '17 04:01 run4flat

Note, mostly to self: see also https://msdn.microsoft.com/en-us/library/windows/desktop/ms686908(v=vs.85).aspx

run4flat avatar Jan 03 '17 04:01 run4flat

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

tsee avatar Jan 04 '17 09:01 tsee