Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-11

Re: Thread REVERT (Ales Katona)

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Thomas Schatzl
Show quoted text 13 lines
From: Ales Katona >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

Reply by email

Ales Katona
to Thomas Schatzl
Thomas Schatzl wrote 47 lines
> From: Ales Katona > >> 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 - 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

Reply by email