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

Ales Katona almindor at gmail.com
Mon Nov 7 16:38:09 CET 2005


Thomas Schatzl wrote:

>> 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) variable.
>
> 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 
> value
>   * 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.
>
> Regards,
>   Thomas
>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>
Thanks, yes it does and it also is a valid point to turn it off with 
threads.

Ales



More information about the fpc-devel mailing list