Commit 9d94003
authored
Keep instantiations alive on failure to prevent use-after-free when a partially-instantiated module writes a function reference to an imported table (#8111)
Fixes #8108. In linking0.wast, a module writes a function reference to
an imported memory but fails to instantiate completely due to an out of
bounds memory access. In this case, the function reference is expected
to stay alive even though instantiation didn't complete, but our code
currently drops the last reference in this case which causes a segfault.
Change the code to keep the reference alive even when instantiation
fails.
This is pessimistic since some modules may fail to instantiate without
writing any references to imported tables, but it avoids dangling
pointers in those cases that do write references.1 parent 4f52bff commit 9d94003
2 files changed
+43
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments