[Unix] Critical Sections do not raise exceptions if not used with cthreads
Original Reporter info from Mantis: tiberius
-
Reporter name: tiberius
Original Reporter info from Mantis: tiberius
- Reporter name: tiberius
Description:
Good morning,
I had problems troubleshooting down the following problem: If I add a critical section within a project on linux which does NOT use cthreads (because in this project (shared library) no extra threads are present) the code for Initialization, Entering, Leaving and Finalization (Done) of a Critical Secion is executed without an error.
But it turns out, that there is no critical section created or entered (the TCriticalSection record stays in its original state). The API documentation does not mention this behavior (https://www.freepascal.org/docs-html/rtl/system/initcriticalsection.html, https://www.freepascal.org/docs-html/rtl/system/entercriticalsection.html). The only hint I could find is the one here: https://www.freepascal.org/docs-html/current/prog/progse45.html "[...] The FPC heap manager uses critical sections when multithreading is enabled. [...]"
There should be an exception on InitCiriticalSecion on Linux if cthreads is not present (like if trying to create and run a TThread without this unit).
Best regards
tiberius
Steps to reproduce:
- Create a library (shared object/dll) which makes use of the same Critical Section in two methods
1. (a) Do NOT make use of the cthreads unit in this library
- Call the library's methods from several threads of another application, which binds this library and try to create a clash
Mantis conversion info:
- Mantis ID: 38090
- Version: 3.2.0