Can anyone think of a reason why you'd get an AV when pressing F8 on a begin statement?

Comments

  1. It depends where the begin statement exists...

    ReplyDelete
  2. start by disabling some plugins... or maybe it's a bug in your [version?] of the IDE

    ReplyDelete
  3. 'begin' in the main program or in a method? If it is in the main program, all 'initialization' blocks are execute when you press F8.

    ReplyDelete
  4. Sorry, begin is at the start of a method

    ReplyDelete
  5. You could display the CPU view and then use F7 to single step thru the assembly code which is between the begin and the first method code line. This assembly code will reserve space for local variable and initialize those having to be initialized.

    ReplyDelete
  6. Virtual Method call on a invalid object reference?
    Or - one of the arguments into the method is a virtual method call on an invalid object reference.

    ReplyDelete
  7. One of the things to check - when the debugger is stopped on the breakpoint (on 'begin'), evaluate 'Self'. Maybe it is 'nil'.

    ReplyDelete
  8. It might not be nil, if you didn't call FreeAndNil ;)

    ReplyDelete
  9. Oh, I am loathe to admit it, but with this codebase I am having to use FreeAndNil -- the pointers are out of control.

    Just like I said in my article. ;-)

    ReplyDelete
  10. Hey, the first thing you have to do before cleaning them all up is make them not AV.  ;-)

    ReplyDelete
  11. And what you have to do before that is to remove all the empty try...except...end blocks!  ;-)  AV's aren't AV's if the user never sees them!!!!

    ReplyDelete
  12. CPU View is your friend for such AVs, begin/end is where all the automatic setup, implicit exception frames, implicit initialization & cleanups go (and they can be mighty complex when the procedure uses strings, interfaces, etc.)

    ReplyDelete

Post a Comment