cannot mix threadvar, exception and range checking on android
Original Reporter info from Mantis: BeniBela @benibela
-
Reporter name: Benito van der Zander
Original Reporter info from Mantis: BeniBela @benibela
- Reporter name: Benito van der Zander
Description:
When a threadvar is read in a function that could throw an exception the program crashes on android, if rangechecking is enabled.
For example:
program huh;
{$mode objfpc}{$H+}
uses
Classes,sysutils;
threadvar test: integer;
procedure decrease;
begin
dec(test);
if test = 0 then begin
writeln('ok');
end else
raise Exception.Create('oh?');
end;
begin
test := 1;
decrease;
end.
when compiled using fpc -Tandroid -Parm -Cr -O3 -gl /tmp/huh.pas
Program received signal SIGSEGV, Segmentation fault.
0xb6f36d0c in DECREASE () at /tmp/huh.pas:13
13 if test = 0 then begin
0xb6f36d04 <+128>: a0 00 9f e5 ldr r0, [pc, #160] ; 0xb6f36dac <DECREASE+296>
0xb6f36d08 <+132>: 21 14 a0 e1 lsr r1, r1, #8
=> 0xb6f36d0c <+136>: 03 10 c0 e5 strb r1, [r0, #3]
0xb6f36d10 <+140>: 00 00 94 e7 ldr r0, [r4, r0]
0xb6f36d14 <+144>: 00 10 90 e5 ldr r1, [r0]
0xb6f36d18 <+148>: 00 00 51 e3 cmp r1, #0
0xb6f36d1c <+152>: 04 00 00 0a beq 0xb6f36d34 <DECREASE+176>
0xb6f36d20 <+156>: 88 20 9f e5 ldr r2, [pc, #136] ; 0xb6f36db0 <DECREASE+300>
0xb6f36d24 <+160>: 02 20 94 e7 ldr r2, [r4, r2]
0xb6f36d28 <+164>: 00 00 92 e5 ldr r0, [r2]
0xb6f36d2c <+168>: 31 ff 2f e1 blx r1
0xb6f36d30 <+172>: 02 00 00 ea b 0xb6f36d40 <DECREASE+188>
0xb6f36d34 <+176>: 74 10 9f e5 ldr r1, [pc, #116] ; 0xb6f36db0 <DECREASE+300>
0xb6f36d38 <+180>: 01 10 94 e7 ldr r1, [r4, r1]
0xb6f36d3c <+184>: 04 00 81 e2 add r0, r1, #4
0xb6f36d40 <+188>: 00 00 90 e5 ldr r0, [r0]
0xb6f36d44 <+192>: 00 00 50 e3 cmp r0, #0
0xb6f36d48 <+196>: 0b 00 00 1a bne 0xb6f36d7c <DECREASE+248>
Mantis conversion info:
- Mantis ID: 31135
- Build: 35148
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 35545 (#fe0e3003)