[fpc-devel] Re: Thread REVERT (Ales Katona)

Thomas Schatzl tom_at_work at gmx.at
Mon Nov 7 13:57:45 CET 2005

> From: Ales Katona <almindor at gmail.com>
>>What about simply disabling such -Ct compiler switch (with nice error
>>message) under Windows ? Or maybe it should "do nothing" under Windows ?
> I have no idea how -Ct works. It seems there are also report(by Pavel to 
> be more precise) that -Ct causes problems with threads in Linux 
> too(Pavel uses his own thread manager so who knows..).
> Unless someone can explain to me how the stack checker knows the right 
> size of stack it should be a rule to turn it off with threads. I'm 
> actualy not sure wether -Ct works ok as-is.
> Ales

Unfortunately the stack checker doesn't know the right size of the stack 
(yet; due to similar problems I am working on that at atm). It assumes 
that the stack is of fixed size, stored in the global "stacklen" (or so) 

When stack checking is enabled, the compiler generates some extra code 
in the function prolog which checks whether the current stack pointer, 
decreased by the amount of stack space this method requires and some 
safety margin, is below the bottom of the stack (a value calculated at 
program start from the initial stack pointer, and the "stacklen" contents).

If this is the case, it gives a RTE 202.

Problems with that:
   * the __stacklen variable is a predetermined (at compile time) fixed 
   * the safety margin is quite high, e.g. 16k, which immediately RTEs 
in threads, because their default stack size is quite low (<= 16k...).

I hope this answers your question.


More information about the fpc-devel mailing list