[fpc-pascal] ansistrings, exceptions, pascal call stack and access violations

Marco van de Voort marcov at stack.nl
Tue Nov 2 23:58:11 CET 2004


> We've got a sophisticated system which relies heavily on the power of ansistrings. I'm now introducing exception handling into the system, and am running into problems with the pascal call stack.
> 
> Without exception handling, I get a nice pascal stack, such as the following (produced by a test program, source below):
> 
> 
> Runtime error 200 at $004010A8
>   $004010A8  TEST_DIVISION_BY_ZERO,  line 13 of e:/c/test/t.pas
>   $00401179  PLAY_WITH_STRINGS,  line 23 of e:/c/test/t.pas
>   $004011B1  main,  line 28 of e:/c/test/t.pas
> 
> 
> However, if I include the sysutils unit, and catch (and reraise) all exceptions, I get the following -- which not only lacks the complete call stack, but includes lots of junk:

I get: (1.9.5 as of today)

-bash-2.05b$ ./exectest 
An unhandled exception occurred at 0x0806CBFC :
EDivByZero : Division by zero
  $0806CBFC  TEST_DIVISION_BY_ZERO,  line 14 of exectest.pp
  $0806CC81  PLAY_WITH_STRINGS,  line 24 of exectest.pp
  $0806CCFF  main,  line 31 of exectest.pp

-bash-2.05b$ 

If I change all occurances of "string" to "ansistring", then:

-bash-2.05b$ ./exectest 
An unhandled exception occurred at 0x0806CC1C :
EDivByZero : Division by zero
  $0806CC1C  TEST_DIVISION_BY_ZERO,  line 14 of exectest.pp
  $BFBFF994  main,  line 22 of /home2/marcov/cvs/devel/fpc/rtl/inc/heap.inc

Are you sure you compiled all units with -gl?

> (compared to the first: notice exception handling is now working, and the
> third line has changed from "main, line 28" to line 30 -- where raise is
> called, rather than where play_with_strings is called)

it sounds like your sysutils is not compiled -gl, however it could also
be a FPC version thing (I'm using a current versioN)






More information about the fpc-pascal mailing list