Repository navigation
Commit 3d60dfa
committed
fix(DexFactory): collect before registering a proxy with the app class loader
ART's mark-compact GC can lose the store of DexCache::location_ when a
collection overlaps ClassLinker::RegisterDexFile. RegisterDexFileLocked
then dereferences the null location and the app dies with SIGSEGV (fault
addr 0x8). Registering into the app's long-lived PathClassLoader, as
DexFactory does for main-runtime proxies since #1968, is the case that
reproduces it; a fresh DexClassLoader per jar never crashed.
A blocking Runtime.gc() right before the injected dex is registered
leaves no collection in flight. In a stress harness and a standalone
repro (no NativeScript code) it took the crash rate from 22-73% of runs
to 0 when the registering thread is the main allocator. It still crashed
once when another thread allocated non-stop, so it narrows the window
rather than closing it. Cost is one explicit GC (about 4-14 ms on
test-suite heaps) on the first use of each runtime-generated proxy.1 parent 8fe217a commit 3d60dfa
1 file changed
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
| |||
0 commit comments