-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Coverage test sys.settrace & improve coverage #17538
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
base: master
Are you sure you want to change the base?
Conversation
Code size report:
|
While there are some other errors going on that also leave me scratching my head, the "expected error" happens on Windows CI, specifically "build-vs (x64, Debug, dev, 2017)".
|
I can't come up with any good theory as to what's making those unix builds fail. It's also a surprise that it's only ONE of the msvc x64 builds. |
While working on extending sys.settrace() with additional capabilities I also noticed that the debug builds are not tested across ports. I first noticed Errors first popping up when building an ESP32 locally. Is there a way to determine coverage locally? |
d134cdb
to
c4d5f09
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17538 +/- ##
==========================================
- Coverage 98.56% 98.23% -0.34%
==========================================
Files 169 171 +2
Lines 21950 22142 +192
==========================================
+ Hits 21636 21751 +115
- Misses 314 391 +77 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Yes, you can go through the steps of the unix coverage build locally. In gcov files show coverage on a line by line basis, with "#####" indicating no coverage of the line, "-" indicating no coverage possible, and a number indicating the number of times the line was covered. The format is described in |
The nanbox build were failing like this:
The reason is that a |
This PR is now read only because it decreases the overall coverage percentage. In reality, it adds coverage to 21751 previously not covered lines. |
Signed-off-by: Jeff Epler <[email protected]>
Signed-off-by: Jeff Epler <[email protected]>
This side-steps the problem where the output does not match when the host python version is 3.12.x (as it is on unix ci today). Signed-off-by: Jeff Epler <[email protected]>
If the fields added for MICROPY_PY_SYS_SETTRACE are not initialized properly, their value in a thread is indeterminate. In particular, if the callback is not NULL, it will be invoked as a function. Signed-off-by: Jeff Epler <[email protected]>
When MICROPY_PY_SYS_SETTRACE was enabled, a crash was seen in the qemu_mips build. It seems likely that this was due to these added fields not being initialized. Signed-off-by: Jeff Epler <[email protected]>
The argument corresponding to a `%q` specifier must be of type `qstr`, not a narrower type like `int16_t`. Not ensuring this caused an assertion error on one Windows x64 build. The argument corresponding to a `%d` specifier must be of type `int`, not a potentially-wider type like `mp_uint_t`. Not ensuring this prevented the function name from being printed on the unix nanbox build. Signed-off-by: Jeff Epler <[email protected]>
I've updated the PR so that settrace is only enabled in the coverage build, not the standard build or other variants. we should consider whether this makes the standard+settrace CI build redundant. I can remove that if desired. the standard+stackless+settrace CI job is probably still useful. |
Yes, that's a good idea. As mentioned, it really decreases performance. OTOH, it's important to get coverage of the settrace code, so enabling it on the coverage build makes sense.
Yes, we can now simplify those CI jobs. These settrace jobs were added in 0b85b5b . Maybe we can replace those two with just a test for stackless mode? Or at least just remove the standard+settrace CI and keep standard+stackless+settrace (as you suggest). |
wrt the work on
That makes it simpler to run that subset during development.
|
Summary
I noticed that
py/profile.c
was not covered at all according to codecov, due to the fact it was never enabled in the unix port.I enabled it, and then added a new test to cover some previously un-covered lines.
Testing
I ran the tests locally and reviewed the coverage of profile.c.
Note: I suspect one or more Windows x64 builds will fail due to improved coverage in this PR, exposing a latent problem.
I wrote a rambling post in the discussions area about passing qstrs to mp_printf. The TL;DR explanation is, there appears to be undefined behavior that occurs when a "small qstr" (
uint16_t
) argument such astype->name
is printed via the%q
format specifier, which retrieves assize_t
value. The specific behavior I saw with x64 msvc on godbolt looked like it would trigger on one specific format string in the core, the repr of frame objects. That's what spurred me to ensure that this code was covered.If the failure does occur, I'll try to write it up properly as an issue.