Commit d9e063f
attach: Gracefully handle file permission errors
When `memray attach` uses a debugger to attach to the target process,
it instructs the process to `dlopen()` a shared library that's part of
Memray. If the Memray install is owned by a different user than the
process being attached to, it's possible the target process won't have
the privileges necessary to load the library. In GDB's case this leads
to an internal error, taking the target process down with the debugger.
Work around this by adding an explicit permission check to the GDB
script and bailing out with a clear error message if the shared library
can't be read. Add a matching error message to the LLDB script, though
for LLDB we can let the `dlopen` run and gracefully handle the failure.
Signed-off-by: Andrew Pan <andrew.pan@trailofbits.com>
Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>1 parent fb215dd commit d9e063f
4 files changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
234 | 241 | | |
235 | 242 | | |
236 | 243 | | |
| |||
0 commit comments