bloomberg / bloomberg/memray

`memray attach` with lldb can trigger an abort due to stack smashing detection

Open
#471 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.2k
Forks
461
Avg merge
5d 3h
Merged PRs (30d)
10

Description

I'm not 100% sure yet what's causing this, and so far I've only been able to reproduce it with lldb, not gdb. But this tiny one-line change to our test suite:
```diff
diff --git a/tests/integration/test_attach.py b/tests/integration/test_attach.py
index f321087..52876ca 100644
--- a/tests/integration/test_attach.py
+++ b/tests/integration/test_attach.py
@@ -91,6 +91,7 @@ def run_process(cmd):
# WHEN
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True)
+ subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True)
except subprocess.CalledProcessError as exc:
if "Couldn't write extended state status" in exc.output:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=898048
```
Is enough to fairly reliably provoke this failure:
```
tests/integration/test_attach.py::test_basic_attach[lldb] *** stack smashing detected ***: /home/mwoznisk/.pyenv/versions/memray-3.11/bin/python terminated
======= Backtrace: =========
/lib64/libc.so.6(__fortify_fail+0x37)[0x7f51f340c7a7]
/lib64/libc.so.6(+0x118762)[0x7f51f340c762]
/home/mwoznisk/repos/memray-pr/src/memray/_memray.cpython-311-x86_64-linux-gnu.so(+0x84eeb)[0x7f51f2e61eeb]
/home/mwoznisk/repos/memray-pr/src/memray/_test_utils.cpython-311-x86_64-linux-gnu.so(+0x149e0)[0x7f51f2a689e0]
...
```

Contributor guide

Open the contributing guide

Research direction

Start with tests/integration/test_attach.py and run test_basic_attach[lldb] after duplicating the subprocess.check_output call in run_process. Inspect the reported stack-smashing backtrace and the involved native extensions to determine the failure. Done means the lldb attach path no longer aborts and the regression is covered by the integration test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.