[fpc-pascal] ansistrings, exceptions, pascal call stack and accessviolations

Peter Vreman peter at freepascal.org
Wed Nov 3 00:32:17 CET 2004


> An unhandled exception occurred at 0x004010A8 :
> EDivByZero : Division by zero
>   $004010A8  TEST_DIVISION_BY_ZERO,  line 13 of e:/c/test/t.pas
>   $666F2033
>
> I noticed in my test program that if I change the ansistring_param to a
> normal string I get the call stack back:
>
>
> An unhandled exception occurred at 0x00401078 :
> EDivByZero : Division by zero
>   $00401078  TEST_DIVISION_BY_ZERO,  line 13 of e:/c/test/t.pas
>   $004010F3  PLAY_WITH_STRINGS,  line 23 of e:/c/test/t.pas
>   $0040116B  main,  line 30 of e:/c/test/t.pas
>

The problem is that the call to the empty ansistring routine will create a
temp ansistring for the parameter. And ansistring variables or temps need
to be finalized. This call to finalize() destroyes the backtrace since it
writes at the same location in the stack that was also used by
test_division_by_zero. We can't solve easily.









More information about the fpc-pascal mailing list