Commit 26e0d44
committed
fix(fixup): patchelf a copy + atomic rename — never rewrite live mappings
The fixup pipeline now runs on every toolchain install path, which means
the process executing it can itself be linked against the very libraries
being patched (a self-hosted mcpp loads the sandbox glibc/libgcc_s).
In-place patchelf rewrites the backing file of those live mappings and
corrupts the running process — reproduced deterministically on fresh-
sandbox CI as an exit-time SIGSEGV in _dl_fini jumping to an unrelocated
address (0x45a0), while a control run of main on the same fresh sandbox
passed (the old code only ever patched from the statically-linked
bootstrap mcpp, so the hazard was structural but unexposed).
patchelf now operates on a copy and atomically rename()s it into place:
the patched content gets a fresh inode, live processes keep the old one.1 parent 24d138e commit 26e0d44
1 file changed
Lines changed: 29 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
63 | 85 | | |
64 | | - | |
| 86 | + | |
65 | 87 | | |
66 | 88 | | |
67 | 89 | | |
68 | | - | |
| 90 | + | |
69 | 91 | | |
70 | 92 | | |
71 | 93 | | |
72 | | - | |
| 94 | + | |
73 | 95 | | |
74 | 96 | | |
75 | 97 | | |
76 | | - | |
| 98 | + | |
77 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
78 | 103 | | |
79 | 104 | | |
80 | 105 | | |
| |||
0 commit comments