Commit e3a301f
authored
Fix test-suite sys.executable leak that skipped free-threaded memory tests (#1066)
Root cause: test_coverup_30::test_scalene_cpu_count constructs Scalene(args)
in-process to check __availableCPUs. Scalene.__init__ runs the full profiler
setup, including scalene.redirect_python.redirect_python -- production
behavior that rewrites sys.executable / sys.path / PATH to a
/tmp/scalene*/python bash wrapper so child processes re-enter through
Scalene. That is correct for a real one-shot 'scalene run' process, but in
the shared, long-lived pytest interpreter it leaks: the test mocks
ScaleneMapFile but not the redirect and never restores the globals.
Every later test that spawns [sys.executable, '-m', 'scalene', ...] then
launched the wrapper instead of real Python, so memory profiling failed to
initialize ([Errno 2] .../tmp/scalene-malloc-signal<pid>) and the memory_*
tests skipped with 'no usable profile' (or, for a few CPU tests, timed out).
Ordering-dependent; it surfaced on free-threaded CI but is not
free-threaded-specific. A full-suite scan found test_coverup_30 to be the
sole polluter.
Fix (minimal, at the source): test_coverup_30's cleanup fixture now
snapshots and restores sys.executable / sys.path / PATH. Verified on Linux
3.13t: the test no longer leaves sys.executable pointing at the wrapper, and
the memory tests pass in suite order even with bare sys.executable in the
spawn helpers.
Also:
- tests/test_memory_stacks_bigmem.py: once the test stopped skipping it
actually ran and exposed a too-strict assertion. The driver's own
list.append() sites legitimately allocate (CPython list-backing-store
growth), so a memory_stacks leaf occasionally lands on the append line,
not make_vec. Require the allocator line to dominate (>=90% of leaf bytes)
instead of being every leaf; the make_big/make_small split asserts are
unchanged.
- tests/conftest.py + tests.yml: a SCALENE_TEST_DIAG-gated hook that prints
each skip's reason live/flushed (off by default; on for t-builds), so skip
reasons survive a job-timeout cancellation for future debugging.1 parent 52aec24 commit e3a301f
4 files changed
Lines changed: 72 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
16 | 26 | | |
17 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
18 | 31 | | |
19 | 32 | | |
20 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
115 | 122 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
120 | 130 | | |
121 | 131 | | |
122 | 132 | | |
| |||
0 commit comments