Skip to content

Exit with a clear message when ptrace_scope blocks the test suite#309

Open
c-tonneslan wants to merge 1 commit into
bloomberg:mainfrom
c-tonneslan:fix/ptrace-scope-preflight
Open

Exit with a clear message when ptrace_scope blocks the test suite#309
c-tonneslan wants to merge 1 commit into
bloomberg:mainfrom
c-tonneslan:fix/ptrace-scope-preflight

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #307.

When Yama's ptrace_scope is set to anything other than 0, pystack can't attach to a running process, so the integration tests hang instead of failing with a useful message.

tests/conftest.py already does a pytest_sessionstart preflight for gcore, so I added a ptrace_scope check right next to it: read /proc/sys/kernel/yama/ptrace_scope, and if it's non-zero, pytest.exit with the command to fix it (sudo sysctl kernel.yama.ptrace_scope=0).

The read is wrapped in try/except OSError, so on a system where that file doesn't exist (non-Linux, or a kernel built without Yama) the check is just a no-op.

If Yama's ptrace_scope is set to anything other than 0, pystack can't
attach to a running process and the integration tests hang instead of
failing. The conftest already does a similar preflight for gcore, so
check ptrace_scope there too and exit with the fix command. Reading
the proc file is wrapped so this is a no-op where the file is absent
(non-Linux, or a kernel without Yama).

Closes bloomberg#307

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Produce a helpful error message if ptrace_scope is 0

1 participant