Commit 5a93a3a
Fix aarch64 JIT crash when cinder_jit region exhausted
Summary:
`allocFromCinderJitRegion()` bump-allocates JIT code out of the fixed-size, linker-reserved `__cinder_jit` region but never checked that the requested size fit in the remaining space. Once the region was exhausted, `s_cinder_jit_free -= size` underflowed (it is a `size_t`) and the function returned `s_cinder_jit_cur` pointing past the end of the mapped RWX region instead of returning `nullptr` to fall back to hinted/`mmap` allocation. The caller (`allocPages` -> `ensureSpace`/`ensureSplitSpace` -> `addCode`) then `memcpy`'d the generated code into unmapped memory, crashing with SIGSEGV in `__folly_memcpy_aarch64_sve` on the JIT compile worker thread. This matches the production aarch64 stack trace.
The fix adds a bounds check inside `cinder_jit_region_mutex_` that returns `nullptr` when `size > s_cinder_jit_free`, so an exhausting or over-large request cleanly falls back to `mmap`. A rejected request consumes no region space.
Reviewed By: alexmalyshev
Differential Revision: D109663217
fbshipit-source-id: 2a22a6c0fe76a1dbc713f7457ee1feefec76708a1 parent 8b6c7ec commit 5a93a3a
2 files changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
92 | 93 | | |
93 | 94 | | |
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 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
95 | 139 | | |
0 commit comments