Commit 20a2568
committed
vm: fix leak in vm.compileFunction when importModuleDynamically is used
Previously in the implementation there was a cycle that V8 could not
detect:
Strong global reference to CompiledFnEntry (JS wrapper)
-> strong reference to callback setting (through the
callbackMap key-value pair)
-> importModuleDynamically (wrapper in internalCompileFunction())
-> Strong reference to the compiled function (through closure in
internalCompileFunction())
The CompiledFnEntry only gets GC'ed when the compiled function is GC'ed.
Since the compiled function is always reachable as described above, there is
a leak.
We only needed the first strong global reference because we didn't want
the function to outlive the CompiledFnEntry. In this case it can be
solved by using a private symbol instead of going with the global
reference + destruction in the weak callback, which V8's GC is not
going to understand.1 parent f32aa19 commit 20a2568
File tree
4 files changed
+19
-14
lines changed- src
- test/pummel
4 files changed
+19
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1263 | 1263 | | |
1264 | 1264 | | |
1265 | 1265 | | |
1266 | | - | |
1267 | | - | |
| 1266 | + | |
1268 | 1267 | | |
1269 | 1268 | | |
1270 | 1269 | | |
| |||
1296 | 1295 | | |
1297 | 1296 | | |
1298 | 1297 | | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | 1298 | | |
1306 | 1299 | | |
1307 | 1300 | | |
1308 | 1301 | | |
1309 | | - | |
1310 | | - | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
1311 | 1306 | | |
1312 | 1307 | | |
1313 | 1308 | | |
1314 | 1309 | | |
1315 | | - | |
1316 | 1310 | | |
1317 | 1311 | | |
1318 | 1312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 197 | | |
201 | 198 | | |
202 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments