Board index » delphi » Stack Overflow

Stack Overflow

Hi

I have a problem when running my application on a certain machine I'm getting a
"Stack Overflow" error message, and on any other machine it gives no problem.

I turned on the {$S+} switch and it didn't help.

Does anyone out there know what causes this problem, please give me a post

Thanks
Sam

 

Re:Stack Overflow


Quote
DataSoftBS wrote:

> Hi

> I have a problem when running my application on a certain machine I'm getting a
> "Stack Overflow" error message, and on any other machine it gives no problem.

> I turned on the {$S+} switch and it didn't help.

> Does anyone out there know what causes this problem, please give me a post

Stack-overflow normally occurs when the actions taken by one method
cause the same event to be triggered, and the method to be invoked
recursively.  While the design of VCL is fairly resistant to that
problem, there are numerous times when I have needed to bypass it
through the use of a boolean flag.

You define the boolean as a private object-variable; therefore you know
it is initially false.  Now in your method you do:

        if not boolean_flag then begin
          try
            boolean_flag := true;
            << original method >>
          finally
            boolean_flag := false;
          end;
        end;

All of the recursions will still occur but they will simply bounce off.

Other Threads