Commit 50bb451
Fix crash when GCing modules reachable via multiple paths
Summary:
Changelog:
* **[Fix]**: Fix incremental build crashing when garbage collecting modules reachable via multiple paths in the graph.
Under the GC algorithm implemented in D36403390 (9065257), the same white ( = marked for deletion) node may be reached multiple times during the "CollectRoots" phase - specifically, if it is the child of two or more white nodes. We had an overly strict null check that caused a crash in this case.
In the test case added to `traverseDependencies-test`, the node that can be reached multiple times is `/baz`:
```
┌─────────────────────────┐
│ ▼
┌─────────┐ / ┌──────┐ ┌──────┐ ┌──────┐
│ /bundle │ ┈/▷ │ /foo │ ──▶ │ /bar │ ──▶ │ /baz │
└─────────┘ / └──────┘ └──────┘ └──────┘
▲ │
└────────────┘
```
A real-world instance of this crash can be seen by launching the default React Native starter app (created with `npx react-native init MyApp`) and deleting the contents of `index.js`. This causes a crash when Metro attempts to collect the `node_modules/babel/runtime/helpers/interopRequireDefault.js` dependency multiple times.
Reviewed By: huntie
Differential Revision: D39416657
fbshipit-source-id: 084b3a0f6363ffc5f51f8cdabc1fc7e81616f4db1 parent e9ee037 commit 50bb451
2 files changed
Lines changed: 41 additions & 4 deletions
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2188 | 2188 | | |
2189 | 2189 | | |
2190 | 2190 | | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
2191 | 2227 | | |
2192 | 2228 | | |
2193 | 2229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
819 | 820 | | |
820 | 821 | | |
821 | 822 | | |
| |||
0 commit comments