[fpc-devel] cthreads and fpc.cfg?

Michael Van Canneyt michael at freepascal.org
Wed Jul 19 12:49:21 CEST 2023

On Wed, 19 Jul 2023, Martin Frb via fpc-devel wrote:

> On 19/07/2023 10:22, Michael Van Canneyt via fpc-devel wrote:
>> The error is logical. What is not logical is that it pops up now.
>> By all logic, we should have seen this error pop up as early as 2016.
>> Why it pops up only now is a mystery that we need to solve...
> I don't have all the details, but maybe there is something buried in the 
> following findings.

Thank you.

We already found the issue. The introduction of unit Types in unit fpmkunit 
(used by fpmake and fpmkcfg) caused a change in the initialization order of units.

Types depends on Math, Math depends on Sysutils -> sysutils was initialized
before cthreads but uses a critical section -> cthreads detected this and
raised an error.

The solution was to remove the use of cthreads in the fpmkunit unit, this is
simply wrong: cthreads may only be used in the program uses clause, since
otherwise there is no telling when the unit will get initialized.

We're looking at removing the dependency of Types on Sysutils:
It stands to reason that defining a simple type should not introduce 
exception support.

We were simply lucky since around 2016 when a critical section was
introduced in sysutils initialization code, necessitating the use 
of cthreads before sysutils.

The solution has been committed and solved the errors you were


More information about the fpc-devel mailing list