Skip to content

Commit 1d4bed4

Browse files
justinmichaudConstellation
authored andcommitted
[Wasm][iOS 27] Intermittent WebContent crash in IPInt cross-instance tail-call restore-frame insertion
https://bugs.webkit.org/show_bug.cgi?id=325447 Reviewed by Yusuke Suzuki and Marcus Plutowski. 1) We fix this crash by following the same pattern as arityFixup. We move the code in almost the most literal way possible from ipint to a thunk, just like arityFixup does. We do a small analysis that this new retag gadget isn't giving a new capabliity that wasn't present before. 2) We add a generated test case that covers exhaustively every combo of jit tier calling eachother in and out of module. We also add some helpers to make this work; I've wanted to add these helpers for a LONG time anyway. 3) We add a tiny reproduction test case. Instead of using wat2wasm, I've chosen to use wabt.js to make this extra portable, similar to my previous EWS fix. Canonical link: https://commits.webkit.org/325486@main
1 parent 4b5c9db commit 1d4bed4

12 files changed

Lines changed: 916 additions & 13 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ requireOptions("--useWasmTailCalls=true")
2+
3+
// f tail-calls g in another instance, which makes IPInt insert a restore frame
4+
// whose return PC points back into the JS-to-wasm entry code.
5+
const module = new WebAssembly.Module(read("tail-call-cross-instance-jit-cage.wasm", "binary"));
6+
const other = new WebAssembly.Instance(module, { m: { g: () => 0 } });
7+
const { f } = new WebAssembly.Instance(module, { m: { g: other.exports.g } }).exports;
8+
9+
for (let i = 0; i < wasmTestLoopCount; ++i) {
10+
if (f() !== 42)
11+
throw new Error("bad result");
12+
}
53 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
;; Tools/Scripts/run-jsc -e "'load(\"JSTests/wasm/libwabt.js\"); WabtModule().then(w => writeFile(\"JSTests/wasm/stress/tail-call-cross-instance-jit-cage.wasm\", w.parseWat(\"x\", read(\"JSTests/wasm/stress/tail-call-cross-instance-jit-cage.wat\"), { tail_call: true }).toBinary({}).buffer))'"
2+
(module
3+
(import "m" "g" (func $g (result i32)))
4+
(func (export "f") (result i32) (return_call $g))
5+
(func (export "g") (result i32) (i32.const 42))
6+
)
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Function indices allowed to compile in BBQ for tail-call-restore-frame-tiers.js: index % 4 is 0 for IPInt, 1 for BBQ, 2 for OMG, 3 for OSR.
2+
1
3+
2
4+
3
5+
5
6+
6
7+
7
8+
9
9+
10
10+
11
11+
13
12+
14
13+
15
14+
17
15+
18
16+
19
17+
21
18+
22
19+
23
20+
25
21+
26
22+
27
23+
29
24+
30
25+
31
26+
33
27+
34
28+
35
29+
37
30+
38
31+
39
32+
41
33+
42
34+
43
35+
45
36+
46
37+
47
38+
49
39+
50
40+
51
41+
53
42+
54
43+
55
44+
57
45+
58
46+
59
47+
61
48+
62
49+
63
50+
65
51+
66
52+
67
53+
69
54+
70
55+
71
56+
73
57+
74
58+
75
59+
77
60+
78
61+
79
62+
81
63+
82
64+
83
65+
85
66+
86
67+
87
68+
89
69+
90
70+
91
71+
93
72+
94
73+
95
74+
97
75+
98
76+
99
77+
101
78+
102
79+
103
80+
105
81+
106
82+
107
83+
109
84+
110
85+
111
86+
113
87+
114
88+
115
89+
117
90+
118
91+
119
92+
121
93+
122
94+
123
95+
125
96+
126
97+
127
98+
129
99+
130
100+
131
101+
133
102+
134
103+
135
104+
137
105+
138
106+
139
107+
141
108+
142
109+
143
110+
145
111+
146
112+
147
113+
149
114+
150
115+
151
116+
153
117+
154
118+
155
119+
157
120+
158
121+
159
122+
161
123+
162
124+
163
125+
165
126+
166
127+
167
128+
169
129+
170
130+
171
131+
173
132+
174
133+
175
134+
177
135+
178
136+
179
137+
181
138+
182
139+
183
140+
185
141+
186
142+
187
143+
189
144+
190
145+
191
146+
193
147+
194
148+
195
149+
197
150+
198
151+
199

0 commit comments

Comments
 (0)