Exit with a clear message when ptrace_scope blocks the test suite#309
Open
c-tonneslan wants to merge 1 commit into
Open
Exit with a clear message when ptrace_scope blocks the test suite#309c-tonneslan wants to merge 1 commit into
c-tonneslan wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #307.
When Yama's
ptrace_scopeis set to anything other than0, pystack can't attach to a running process, so the integration tests hang instead of failing with a useful message.tests/conftest.pyalready does apytest_sessionstartpreflight forgcore, so I added aptrace_scopecheck right next to it: read/proc/sys/kernel/yama/ptrace_scope, and if it's non-zero,pytest.exitwith 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.