Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyflame: fix the build on machines with kernel.yama.ptrace_scope > 0 #52828

Merged
merged 2 commits into from Sep 6, 2019

Conversation

ivan
Copy link
Member

@ivan ivan commented Dec 25, 2018

Motivation for this change

This fixes #52827. cc'ing maintainer @symphorien for feedback.

Users of pyflame need to have kernel.yama.ptrace_scope = 0 anyway, but it still seems useful for a machine with a hardened profile to be able to build it.

I considered asking upstream to add some skipIf when ptrace_scope > 1, but it doesn't look like they're working on pyflame right now.

I tested this PR with kernel.yama.ptrace_scope = 0 and = 1:

with ptrace_scope = 0:

============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-3.9.3, py-1.7.0, pluggy-0.8.0 -- /nix/store/zj4rl3lpr79hlzc8hqz2pwdb6zwbdpbn-python3-3.5.6/bin/python3.5m
cachedir: .pytest_cache
rootdir: /build/source, inifile:
collecting ... collected 37 items

tests/test_end_to_end.py::test_travis_build_environment SKIPPED          [  2%]
tests/test_end_to_end.py::test_rpm_build_environment PASSED              [  5%]
tests/test_end_to_end.py::test_monitor PASSED                            [  8%]
tests/test_end_to_end.py::test_non_gil PASSED                            [ 10%]
tests/test_end_to_end.py::test_threaded PASSED                           [ 13%]
tests/test_end_to_end.py::test_unthreaded PASSED                         [ 16%]
tests/test_end_to_end.py::test_legacy_pid_handling PASSED                [ 18%]
tests/test_end_to_end.py::test_legacy_pid_handling_too_many_pids PASSED  [ 21%]
tests/test_end_to_end.py::test_dash_t_and_dash_p PASSED                  [ 24%]
tests/test_end_to_end.py::test_unsupported_abi PASSED                    [ 27%]
tests/test_end_to_end.py::test_exclude_idle PASSED                       [ 29%]
tests/test_end_to_end.py::test_utf8_output SKIPPED                       [ 32%]
tests/test_end_to_end.py::test_exit_early PASSED                         [ 35%]
tests/test_end_to_end.py::test_sample_not_python PASSED                  [ 37%]
tests/test_end_to_end.py::test_trace[False-False] PASSED                 [ 40%]
tests/test_end_to_end.py::test_trace[False-True] PASSED                  [ 43%]
tests/test_end_to_end.py::test_trace[True-False] PASSED                  [ 45%]
tests/test_end_to_end.py::test_trace[True-True] PASSED                   [ 48%]
tests/test_end_to_end.py::test_trace_not_python PASSED                   [ 51%]
tests/test_end_to_end.py::test_pyflame_a_pyflame PASSED                  [ 54%]
tests/test_end_to_end.py::test_pyflame_nonexistent_file PASSED           [ 56%]
tests/test_end_to_end.py::test_trace_no_arg PASSED                       [ 59%]
tests/test_end_to_end.py::test_sample_no_arg PASSED                      [ 62%]
tests/test_end_to_end.py::test_sample_extra_args PASSED                  [ 64%]
tests/test_end_to_end.py::test_permission_error SKIPPED                  [ 67%]
tests/test_end_to_end.py::test_invalid_pid[-1] PASSED                    [ 70%]
tests/test_end_to_end.py::test_invalid_pid[0] PASSED                     [ 72%]
tests/test_end_to_end.py::test_invalid_pid[1606938044258990275541962092341162602522202993782792835301376] PASSED [ 75%]
tests/test_end_to_end.py::test_invalid_pid[not a pid] PASSED             [ 78%]
tests/test_end_to_end.py::test_include_ts PASSED                         [ 81%]
tests/test_end_to_end.py::test_include_ts_exclude_idle PASSED            [ 83%]
tests/test_end_to_end.py::test_version[-v] PASSED                        [ 86%]
tests/test_end_to_end.py::test_version[--version] PASSED                 [ 89%]
tests/test_end_to_end.py::test_trace_forker PASSED                       [ 91%]
tests/test_end_to_end.py::test_sigchld PASSED                            [ 94%]
tests/test_end_to_end.py::test_thread_dump PASSED                        [ 97%]
tests/test_end_to_end.py::test_no_line_numbers PASSED                    [100%]

==================== 34 passed, 3 skipped in 21.90 seconds =====================

with ptrace_scope = 1:

============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-3.9.3, py-1.7.0, pluggy-0.8.0 -- /nix/store/zj4rl3lpr79hlzc8hqz2pwdb6zwbdpbn-python3-3.5.6/bin/python3.5m
cachedir: .pytest_cache
rootdir: /build/source, inifile:
collecting ... collected 37 items

tests/test_end_to_end.py::test_travis_build_environment SKIPPED          [  2%]
tests/test_end_to_end.py::test_rpm_build_environment PASSED              [  5%]
tests/test_end_to_end.py::test_monitor SKIPPED                           [  8%]
tests/test_end_to_end.py::test_non_gil SKIPPED                           [ 10%]
tests/test_end_to_end.py::test_threaded SKIPPED                          [ 13%]
tests/test_end_to_end.py::test_unthreaded SKIPPED                        [ 16%]
tests/test_end_to_end.py::test_legacy_pid_handling SKIPPED               [ 18%]
tests/test_end_to_end.py::test_legacy_pid_handling_too_many_pids PASSED  [ 21%]
tests/test_end_to_end.py::test_dash_t_and_dash_p PASSED                  [ 24%]
tests/test_end_to_end.py::test_unsupported_abi PASSED                    [ 27%]
tests/test_end_to_end.py::test_exclude_idle SKIPPED                      [ 29%]
tests/test_end_to_end.py::test_utf8_output SKIPPED                       [ 32%]
tests/test_end_to_end.py::test_exit_early SKIPPED                        [ 35%]
tests/test_end_to_end.py::test_sample_not_python SKIPPED                 [ 37%]
tests/test_end_to_end.py::test_trace[False-False] PASSED                 [ 40%]
tests/test_end_to_end.py::test_trace[False-True] PASSED                  [ 43%]
tests/test_end_to_end.py::test_trace[True-False] PASSED                  [ 45%]
tests/test_end_to_end.py::test_trace[True-True] PASSED                   [ 48%]
tests/test_end_to_end.py::test_trace_not_python PASSED                   [ 51%]
tests/test_end_to_end.py::test_pyflame_a_pyflame PASSED                  [ 54%]
tests/test_end_to_end.py::test_pyflame_nonexistent_file PASSED           [ 56%]
tests/test_end_to_end.py::test_trace_no_arg PASSED                       [ 59%]
tests/test_end_to_end.py::test_sample_no_arg PASSED                      [ 62%]
tests/test_end_to_end.py::test_sample_extra_args PASSED                  [ 64%]
tests/test_end_to_end.py::test_permission_error SKIPPED                  [ 67%]
tests/test_end_to_end.py::test_invalid_pid[-1] PASSED                    [ 70%]
tests/test_end_to_end.py::test_invalid_pid[0] PASSED                     [ 72%]
tests/test_end_to_end.py::test_invalid_pid[1606938044258990275541962092341162602522202993782792835301376] PASSED [ 75%]
tests/test_end_to_end.py::test_invalid_pid[not a pid] PASSED             [ 78%]
tests/test_end_to_end.py::test_include_ts SKIPPED                        [ 81%]
tests/test_end_to_end.py::test_include_ts_exclude_idle SKIPPED           [ 83%]
tests/test_end_to_end.py::test_version[-v] PASSED                        [ 86%]
tests/test_end_to_end.py::test_version[--version] PASSED                 [ 89%]
tests/test_end_to_end.py::test_trace_forker PASSED                       [ 91%]
tests/test_end_to_end.py::test_sigchld PASSED                            [ 94%]
tests/test_end_to_end.py::test_thread_dump SKIPPED                       [ 97%]
tests/test_end_to_end.py::test_no_line_numbers SKIPPED                   [100%]

==================== 22 passed, 15 skipped in 12.10 seconds ====================
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS not supported
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@symphorien
Copy link
Member

IIRC the policy of nixpkgs is to minimize downstream or inline patches.
You should probably use fetchpatch to get the patch in 9dedbfc (we don't have to wait for upstream to merge the PR, the only important thing is that the url for patches is stable).
Maybe, as you mentioned, disabling the tests when ptrace is restricted would be worth a PR to upstream, and here again we can fetchpatch the PR even before it is merged. But I grant you that it is a matter of opinion.
In any case, thanks :)

@mmahut
Copy link
Member

mmahut commented Aug 13, 2019

Are there any updates on this pull request, please?

@ivan
Copy link
Member Author

ivan commented Aug 13, 2019

@GrahamcOfBorg build pyflame

@ivan
Copy link
Member Author

ivan commented Aug 13, 2019

Updated for master, please review.

I removed my commit that adds the patch because nixpkgs is already applying it now.

@symphorien
Copy link
Member

Looks good to me.

@ivan
Copy link
Member Author

ivan commented Aug 28, 2019

ping @FRidh, you were last to commit to pyflame

@FRidh
Copy link
Member

FRidh commented Sep 6, 2019

@ivan I submitted it ;-)

@FRidh FRidh merged commit 96a099a into NixOS:master Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyflame build fails with hardened profile or kernel.yama.ptrace_scope = 1
5 participants