"assert", raises exception with wrong code/frame-address
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
Assert has a similar issue as #12528 (closed)
Procedure AssertErrorHandler (Const Msg,FN : ShortString;LineNo:longint; TheAddr : pointer);
Var S : String;
begin
If Msg='' then S:=SAssertionFailed else S:=Msg;
Raise EAssertionFailed.Createfmt(SAssertError,[S,Fn,LineNo]) at Pointer(theAddr);
end;
When the compiler creates code for assert (w32/i386) it bushes the current value of ebp on the stack (same as "get_frame" would return).
As you can see, in the above code, the value of ebp is used as the address of the code raising the assert. This value does not even point to any code at all.
As in #12528 (closed) the frame is set to 0x0
My understanding is, that the code should be
Raise EAssertionFailed.Createfmt(SAssertError,[S,Fn,LineNo]) at get_caller_addr(theAddr), get_caller_frame(theAddr);
Steps to reproduce:
trigger an assert, and inspect the argument to fpc_raiseexception
Mantis conversion info:
- Mantis ID: 19310
- OS: win
- OS Build: vista
- Platform: w32
- Version: 2.5.1
- Fixed in version: 2.6.0
- Fixed in revision: 17470 (#7de8972e)