Re: Crashing on LOOP instruction (ARMV7-A)

  • From: Oleg Volosin <oleg@xxxxxxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Mon, 6 Aug 2018 19:44:42 +0000



this code looks identical to the next example, so i guess it's a
copy/paste error and it actually had less than 56 iterations.  If so,
the loop doesn't get "hot" and no code is JITted, so there's nothing
for dump to do.


A copy/paste mistake indeed! Sorry.

You are definitely right Javier. The first case has only 10 iterations. The 
second has 100. 

I wasn't aware JIT kicks in above 56 iterations. It really looks like the issue 
has nothing to do with loops in particular. Must be falling down on the very 
first attempt to emit/run JITed instructions.

Thanks Javier!


Oleg


On 6 Aug 2018, at 18:20, Javier Guerra Giraldez <javier@xxxxxxxxxxx> wrote:

On 6 August 2018 at 18:07, Oleg Volosin <oleg@xxxxxxxxxxxxxx> wrote:
Dear LuaJIT community

I'm trying to build LuaJIT 2.0.5 for QNX 6.6.0 (POSIX system) running on
32-bit ARM Cortex-A15 SoC.

No issues cross-building 2.0.5 as per LuaJIT "installation" doc. Both luajit
and luajit.so binaries get built OK.

I can also run the scripts with JIT VM tuned off (-j off).

However with JIT enabled it keeps crashing around LOOP instruction in a
somewhat strange manner around LOOP instruction. I also don't quite
understand how the 'dump' option is expected to work, it seems to be
behaving somewhat inconsistently.


########################################################
E.g. the following script runs OK, no crashing (and no dump!?):

print(">>>");
local times = 100;
while times > 0 do
   times = times - 1;
end
print("<<<");



luajit -j dump test.lua

<<<


this code looks identical to the next example, so i guess it's a
copy/paste error and it actually had less than 56 iterations.  If so,
the loop doesn't get "hot" and no code is JITted, so there's nothing
for dump to do.





########################################################
Same script with increased number of iterations to 100 is crashing:

print(">>>");
local times = 100;
while times > 0 do
   times = times - 1;
end
print("<<<");



luajit -j dump test.lua

---- TRACE 1 start test.lua:4
0009  SUBVN    0   0   0  ; 1
0010  JMP      1 => 0005
0005  KSHORT   1   0
0006  ISGE     1   0
0007  JMP      1 => 0011
0008  LOOP     1 => 0011
Memory fault


now the loop is detected as "hot" after 56 iterations, so it gets
traced and you get the dump.  it shows only the bytecode, and not the
IR or mcode, so I guess the fault happens before closing the trace.






##############################################################
Same script with 100 iteration loop AND printing the counter no longer
crashing

print(">>>");
local times = 100;
while times > 0 do
   printf(times);
   times = times - 1;
end
print("<<<");


luajit -j dump test.lua

100
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
---- TRACE 1 start test.lua:4
0009  GGET     1   0      ; "print"
0010  MOV      2   0
0011  CALL     1   1   2
0000  . FUNCC               ; print
---- TRACE 1 abort test.lua:5 -- NYI: FastFunc print

45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
---- TRACE 1 start test.lua:4
0009  GGET     1   0      ; "print"
0010  MOV      2   0
0011  CALL     1   1   2
0000  . FUNCC               ; print
---- TRACE 1 abort test.lua:5 -- NYI: FastFunc print

8
7
6
5
4
3
2
1
<<<

the print() function isn't compilable (check the NYI list), so the
tracing aborts and the code isn't compiled.  it seems to happen before
the fault seen on the other runs.

if you want to have output, use io:write() instead.


i guess you do have found a bug, but all other things (too few
iteratioins, NYI function) prevent the compilation in those cases,
hiding the problem.

-- 
Javier



Other related posts: