[fpc-pascal] Debug Advice needed

James Richters james at productionautomation.net
Tue May 21 13:34:54 CEST 2019

I have this program that is confounding me.    It obtains a file name with GetOpenFileNameA then it processes the file and draws stuff on the screen, then loops back and gets another file name until GetOpenFileNameA returns a false… so as long as I keep giving it files it keeps running and if I cancel the file selection, it exits.    It will run in a loop like this various numbers of times… sometimes 4 times, sometimes 8 times, sometimes twice, sometimes 30 times and then I get this access violation like this:


An unhandled exception occurred at $0040ED07:

EAccessViolation: Access violation




  $00402255  PLOTDRAWPAX,  line 76 of i:/programming/gcode/mill/plotdraw.pax.pas

  $00402705  main,  line 119 of i:/programming/gcode/mill/plotdraw.pax.pas


Line 76 is the a call to a procedure in another unit that’s very complicated and calls a lot of other functions and procedures.

I keep testing with the same 5 files over and over, and each file has processed fine many times so there isn’t a problem with the data in my files or the way I am processing it….  and there doesn’t seem to be a particular file that causes this.   I’m thinking I have some memory issue or something is not freeing or ? 


It’s also not always the same exact message.. sometimes I get 


An unhandled exception occurred at $0040ED07:

EAccessViolation: Access violation


  $004026DB  main,  line 118 of i:/programming/gcode/mill/plotdraw.pax.pas


Line 118 is a call to a function that is in no way related to the procedure that is called on line 76… it’s actually a ridiculously simple function.  Exactly one line of code to it, and I have run that function millions of times with other programs that use the same unit.


The FPC text IDE is reporting runtime error 217 which doesn’t tell me much.. just an unhandled exception occurred.


My question is… how do I track these kinds of things down?    Is there a way I can use the hex addresses to see more precisely what caused the error?  

I’m confused why sometimes I get very detailed debug reports that get me to the exact command that caused the problem and other times I have some information but then it just stops and I have nothing following the hex addresses.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190521/3d5c12de/attachment.html>

More information about the fpc-pascal mailing list