Wrong register used for fpc_check_object in compilers asm code, that cause EAccessViolation.
Original Reporter info from Mantis: fvi
-
Reporter name: Filiuta Vitali
Original Reporter info from Mantis: fvi
- Reporter name: Filiuta Vitali
Description:
Troublemaker code and asm file attached.
execute result:
An unhandled exception occurred at $00402B27:
EAccessViolation: Access violation
$00402B27
$0040174D SETMEMORY, line 12 of app_test_core.pas
$00401813 main, line 27 of app_test_core.pas
error here:
procedure SetMemory(Stream: TStream; var P: Pointer; var PSize: Integer);
begin
PSize := Stream.Size;
GetMem(P, PSize);
Stream.Position := 0;
Stream.Read(P^, PSize); // <-- Line 12, error here
end;
asm of "Stream.Read(P^, PSize);":
# -8(%ebp) - @P # -4(%ebp) - @PSize # -16(%ebp) - Stream
# [12] Stream.Read(P^, PSize);
movl -8(%ebp),%eax
movl (%eax),%edx <-------------- %edx = P ; %eax = @P
movl %edx,-12(%ebp)
movl -4(%ebp),%eax
movl (%eax),%edi <-------------- %edi = PSize ; %eax = @PSize
movl -16(%ebp),%esi <----------- %esi = Stream
# Var Stream located in register eax
movl %eax,%ebx <---------------- from here %eax = @PSize used to check Stream object
testl %ebx,%ebx
jne .Lj16
call fpc_objecterror
.balign 4,0x90
.Lj16:
movl (%ebx),%ebx
movl %ebx,%eax
call fpc_check_object
movl %esi,%eax
movl %edi,%ecx
movl -12(%ebp),%edx
call *128(%ebx)
.stabn 68,0,13,.Ll6 - P$APP_TEST_CORE_$$_SETMEMORY$TSTREAM$POINTER$LONGINT
.Ll6:
# [13] end;
Mantis conversion info:
- Mantis ID: 33565
- OS: Windows
- OS Build: 10
- Build: r38673
- Platform: i386
- Version: 3.1.1
- Fixed in version: 3.3.1
- Fixed in revision: 43384 (#c6659d62)