View Issue Details

IDProjectCategoryView StatusLast Update
0038090FPCDocumentationpublic2020-11-17 09:25
Reportertiberius Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version3.2.0 
Summary0038090: [Unix] Critical Sections do not raise exceptions if not used with cthreads
DescriptionGood 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 Reproduce1. 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
2. Call the library's methods from several threads of another application, which binds this library and try to create a clash
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Michael Van Canneyt

2020-11-17 09:25

administrator   ~0126995

As far as I know, this is by design, but I will document it. Changed the category to documentation.

Issue History

Date Modified Username Field Change
2020-11-17 08:04 tiberius New Issue
2020-11-17 09:24 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-11-17 09:24 Michael Van Canneyt Status new => assigned
2020-11-17 09:24 Michael Van Canneyt Category RTL => Documentation
2020-11-17 09:24 Michael Van Canneyt FPCTarget => -
2020-11-17 09:25 Michael Van Canneyt Note Added: 0126995