Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
Commita86a2e1
module: use symbol in WeakMap to manage host defined options
Previously when managing the importModuleDynamically callback ofvm.compileFunction(), we use an ID number as the host defined optionand maintain a per-Environment ID -> CompiledFnEntry map to retainthe top-level referrer function returned by vm.compileFunction() inorder to pass it back to the callback, but it would leak because withhow we used v8::Persistent to maintain this reference, V8 would notbe able to understand the cycle and would just think that theCompiledFnEntry was supposed to live forever. We made an attemptto make that reference known to V8 by making the CompiledFnEntry weakand using a private symbol to make CompiledFnEntry stronglyreferences the top-level referrer function in#46785, but that turned out to beunsound, because the there's no guarantee that the top-level functionmust be alive while import() can still be initiated from thatfunction, since V8 could discard the top-level function and only keepinner functions alive, so relying on the top-level function to keepthe CompiledFnEntry alive could result in use-after-free which causeda revert of that fix.With this patch we use a symbol in the host defined options instead ofa number, because with the stage-3 symbol-as-weakmap-keys proposalwe could directly use that symbol to keep the referrer alive using aWeakMap. As a bonus this also keeps the other kinds of referrersalive as long as import() can still be initiated from thatScript/Module, so this also fixes the long-standing crash caused byvm.Script being GC'ed too early when its importModuleDynamicallycallback still needs it.PR-URL:#48510Backport-PR-URL:#51004Refs:#44211Refs:#42080Refs:#47096Refs:#43205Refs:#38695Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>1 parent2c2892b commita86a2e1
File tree
16 files changed
+185
-191
lines changed- lib
- internal
- modules/esm
- vm
- src
- test/es-module
16 files changed
+185
-191
lines changedLines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 |
| - | |
73 |
| - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
74 | 75 |
| |
75 | 76 |
| |
76 | 77 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
213 |
| - | |
| 213 | + | |
214 | 214 |
| |
215 |
| - | |
| 215 | + | |
| 216 | + | |
216 | 217 |
| |
217 | 218 |
| |
218 | 219 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
150 | 150 |
| |
151 | 151 |
| |
152 | 152 |
| |
153 |
| - | |
154 |
| - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
155 | 156 |
| |
156 | 157 |
| |
157 | 158 |
| |
|
Lines changed: 69 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 |
| |
11 | 16 |
| |
12 | 17 |
| |
| |||
21 | 26 |
| |
22 | 27 |
| |
23 | 28 |
| |
24 |
| - | |
25 |
| - | |
26 |
| - | |
27 | 29 |
| |
28 | 30 |
| |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
34 | 31 |
| |
35 | 32 |
| |
36 | 33 |
| |
| |||
83 | 80 |
| |
84 | 81 |
| |
85 | 82 |
| |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
86 | 136 |
| |
87 | 137 |
| |
88 |
| - | |
| 138 | + | |
89 | 139 |
| |
90 | 140 |
| |
91 |
| - | |
92 |
| - | |
93 |
| - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
94 | 144 |
| |
95 |
| - | |
| 145 | + | |
96 | 146 |
| |
97 | 147 |
| |
98 | 148 |
| |
99 | 149 |
| |
100 | 150 |
| |
101 | 151 |
| |
102 |
| - | |
| 152 | + | |
103 | 153 |
| |
104 | 154 |
| |
105 | 155 |
| |
106 | 156 |
| |
107 | 157 |
| |
108 |
| - | |
109 |
| - | |
110 |
| - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
111 | 161 |
| |
112 |
| - | |
113 |
| - | |
| 162 | + | |
114 | 163 |
| |
115 | 164 |
| |
116 | 165 |
| |
| |||
176 | 225 |
| |
177 | 226 |
| |
178 | 227 |
| |
179 |
| - | |
| 228 | + | |
180 | 229 |
| |
181 | 230 |
| |
182 | 231 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
|
Lines changed: 9 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 |
| - | |
16 | 15 |
| |
17 | 16 |
| |
18 | 17 |
| |
| |||
70 | 69 |
| |
71 | 70 |
| |
72 | 71 |
| |
73 |
| - | |
74 | 72 |
| |
75 | 73 |
| |
76 | 74 |
| |
| |||
121 | 119 |
| |
122 | 120 |
| |
123 | 121 |
| |
| 122 | + | |
124 | 123 |
| |
125 | 124 |
| |
126 | 125 |
| |
127 | 126 |
| |
128 |
| - | |
129 |
| - | |
| 127 | + | |
| 128 | + | |
130 | 129 |
| |
131 | 130 |
| |
132 | 131 |
| |
133 | 132 |
| |
134 |
| - | |
| 133 | + | |
135 | 134 |
| |
136 | 135 |
| |
137 | 136 |
| |
138 | 137 |
| |
139 | 138 |
| |
140 | 139 |
| |
141 | 140 |
| |
142 |
| - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
143 | 146 |
| |
144 | 147 |
| |
145 | 148 |
| |
| |||
446 | 449 |
| |
447 | 450 |
| |
448 | 451 |
| |
449 |
| - | |
450 | 452 |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
109 |
| - | |
110 |
| - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
|
Lines changed: 0 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
345 | 345 |
| |
346 | 346 |
| |
347 | 347 |
| |
348 |
| - | |
349 |
| - | |
350 |
| - | |
351 |
| - | |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 | 348 |
| |
359 | 349 |
| |
360 | 350 |
| |
|
Lines changed: 0 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
698 | 698 |
| |
699 | 699 |
| |
700 | 700 |
| |
701 |
| - | |
702 |
| - | |
703 |
| - | |
704 |
| - | |
705 |
| - | |
706 |
| - | |
707 |
| - | |
708 |
| - | |
709 | 701 |
| |
710 | 702 |
| |
711 | 703 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| |||
337 | 338 |
| |
338 | 339 |
| |
339 | 340 |
| |
340 |
| - | |
341 | 341 |
| |
342 | 342 |
| |
343 | 343 |
| |
|
0 commit comments
Comments
(0)