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

Improve Cython coverage #98

Merged
merged 12 commits into from
May 22, 2023
Merged

Conversation

godlygeek
Copy link
Contributor

This PR gets all but one line of _pystack.pyx covered by our test suite.

I'm leaning towards believing that line is dead code, but I'm not yet confident enough to remove it...

@godlygeek godlygeek self-assigned this May 4, 2023
Simulate failures to find the heap and BSS as well as failures to
correctly resolve the heap address in order to exercise our error
handling code.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@codecov-commenter
Copy link

codecov-commenter commented May 4, 2023

Codecov Report

Patch coverage: 99.25% and project coverage change: +0.88 🎉

Comparison is base (4a73dad) 89.46% compared to head (23a7767) 90.34%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   89.46%   90.34%   +0.88%     
==========================================
  Files          46       47       +1     
  Lines        5419     5480      +61     
  Branches      845      863      +18     
==========================================
+ Hits         4848     4951     +103     
+ Misses        571      529      -42     
Flag Coverage Δ
cpp 75.18% <66.66%> (+0.24%) ⬆️
python_and_cython 99.97% <100.00%> (+1.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pystack/_pystack/mem.cpp 86.80% <66.66%> (+2.19%) ⬆️
src/pystack/_pystack.pyx 99.76% <100.00%> (+8.07%) ⬆️
tests/integration/test_core_analyzer.py 100.00% <100.00%> (ø)
tests/integration/test_process.py 100.00% <100.00%> (ø)
tests/unit/test_extension.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Ensure that `@intercept_runtime_errors` actually does intercept
`RuntimeError`, and exercise all paths in `_check_interpreter_shutdown`.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Since we never configure the level of `LOGGER`, it's always
`logging.NOTSET`, and no log level is ever lower than `NOTSET`,
so this early return is never taken.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
Nothing ever calls `copy_memory_from_address` with `blocking=True`, so
we can safely remove this code path and unconditionally use the
nonblocking version.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
`map_info.python` is annotated as a non-optional `VirtualMap`, and
`parse_maps_file_for_binary` will never set it to `None`, so this
conditional never triggers.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
In order to pass the `errno` returned from the failed `ptrace` call to
`std::system_error`, we need to save it in a temporary to stop it from
being overwritten by the calls we make in `detachFromProcess`.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
These values don't match the actual declaration in `process.h`. Since
Cython doesn't use or need to know the values, just remove them, to
avoid misleading future readers.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
This also raises code coverage.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
This should never happen unless we've badly screwed something up or
memory has been trashed (as variable names ought to always be valid
Unicode strings), but we can both improve coverage and improve the
failure mode by explicitly specifying an error handling method.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
There is no path where `getThreadFromInterpreterState` can return an
unset shared pointer, so this conditional will never fire.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
@godlygeek godlygeek marked this pull request as ready for review May 4, 2023 22:28
@godlygeek
Copy link
Contributor Author

@pablogsal I'd like your review here specifically, since I did make some changes to the implementation (deleting some code I believe to be dead, and restructuring some code to be easier to exercise).

I've attempted to roughly arrange the commits from least controversial to most.

@sarahmonod sarahmonod requested a review from pablogsal May 10, 2023 12:55
Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed every commit individually and the change itself as a whole and executed everything locally and coud not find anything I don't like. Excellent job!

@pablogsal pablogsal merged commit 2d2fa4b into bloomberg:main May 22, 2023
22 checks passed
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.

None yet

3 participants