Debug Advice needed

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Debug Advice needed

Zaaphod

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

  $0040ED07

  $00411A6C

  $00411F25

  $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

  $0040ED07

  $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.

 

James


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Debug Advice needed

Alexander Grotewohl
I'm not sure your familiarity with debuggers but you would set a breakpoint inside your code and step through until it crashes, perhaps watching a few variables to ensure their contents are correct.

Since it would work similar to turbo pascal and by extension, more modern "clone"/work-alikes, the virtual pascal VP21USER.PDF debugging section might be useful for learning that stuff.

--
Alexander Grotewohl
http://dcclost.com

On May 21, 2019 7:34 AM, James Richters <[hidden email]> wrote:

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

  $0040ED07

  $00411A6C

  $00411F25

  $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

  $0040ED07

  $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.

 

James



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal