Skip to content

Commit fa03554

Browse files
committed
Give up analyzing looped stack after 10000 iterations
Temporary fix for an infinite loop, to be properly fixed later
1 parent e1ad53e commit fa03554

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

src/compiler/iroptimizer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,21 @@ class IROptimizer {
627627
return this.analyzeStack(stack, state) || modified;
628628
}
629629

630+
let iterations = 0;
630631
let modified = false;
631632
let keepLooping;
632633
do {
634+
// If we are stuck in an apparent infinite loop, give up and assume the worst.
635+
if (iterations > 10000) {
636+
console.error('analyzeLoopedStack stuck in likely infinite loop; quitting', block, state);
637+
modified = state.clear();
638+
block.entryState = state.clone();
639+
block.exitState = state.clone();
640+
modified = this.analyzeInputs(block.inputs, state) || modified;
641+
return this.analyzeStack(stack, state) || modified;
642+
}
643+
iterations++;
644+
633645
const newState = state.clone();
634646
modified = this.analyzeStack(stack, newState) || modified;
635647
modified = (keepLooping = state.or(newState)) || modified;
34.4 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// TW Snapshot
2+
// Input SHA-256: a12680688ca945364abe1e094b35cf53326f70189cb09b58d5f52b4de0c3b2a9
3+
4+
// Text script
5+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
6+
const b0 = runtime.getOpcodeFunction("looks_say");
7+
return function* genXYZ () {
8+
yield* executeInCompatibilityLayer({"MESSAGE":"plan 0",}, b0, false, false, "a~", null);
9+
thread.procedures["Wtest 1"]();
10+
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "dh", null);
11+
retire(); return;
12+
}; })
13+
14+
// Text Wtest 1
15+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
16+
const b0 = target.variables["ts-.PQ{/]mN_9@MbG:m/"];
17+
return function funXYZ_test_1 () {
18+
for (var a0 = (+thread.procedures["Wany procedure reporter"]() || 0); a0 >= 0.5; a0--) {
19+
b0.value = ((+b0.value || 0) + 1);
20+
}
21+
return "";
22+
}; })
23+
24+
// Text Wany procedure reporter
25+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
26+
return function funXYZ_any_procedure_report () {
27+
return 0;
28+
return "";
29+
}; })
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// TW Snapshot
2+
// Input SHA-256: a12680688ca945364abe1e094b35cf53326f70189cb09b58d5f52b4de0c3b2a9
3+
4+
// Text script
5+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
6+
const b0 = runtime.getOpcodeFunction("looks_say");
7+
return function* genXYZ () {
8+
yield* executeInCompatibilityLayer({"MESSAGE":"plan 0",}, b0, false, false, "a~", null);
9+
yield* thread.procedures["Wtest 1"]();
10+
yield* executeInCompatibilityLayer({"MESSAGE":"end",}, b0, false, false, "dh", null);
11+
retire(); return;
12+
}; })
13+
14+
// Text Wtest 1
15+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
16+
const b0 = target.variables["ts-.PQ{/]mN_9@MbG:m/"];
17+
return function* genXYZ_test_1 () {
18+
for (var a0 = (+thread.procedures["Wany procedure reporter"]() || 0); a0 >= 0.5; a0--) {
19+
b0.value = ((+b0.value || 0) + 1);
20+
if (isStuck()) yield;
21+
}
22+
return "";
23+
}; })
24+
25+
// Text Wany procedure reporter
26+
(function factoryXYZ(thread) { const target = thread.target; const runtime = target.runtime; const stage = runtime.getTargetForStage();
27+
return function funXYZ_any_procedure_report () {
28+
return 0;
29+
return "";
30+
}; })

0 commit comments

Comments
 (0)