Repository navigation
fix(tools): stop expanding a helper's branches once one rules it out as a stub - #27805
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change is sound based on the changed implementation and tests read; no checks were run during this review.
What I ran
Read the prepared diff and the pinned head c916d39fa7e9a7172901bade07bbda0e2491d298 using repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and implementation review | passed | Early stop matches helper classification |
| Tests | not run | Author-reported results were not rerun |
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not inspect the rest of tools/import_audit.py or tools/tests/test_import_audit.py; did not run tests or verify the author-reported platform and full-suite results. Both changed files are included in the reviewed manifest and their relevant changed functions and test cases were read. No excluded changed files are listed.
To get this to a good state
Nothing is required.
JJenkx
left a comment
There was a problem hiding this comment.
Independent Linux verification at c916d39fa7e9a7172901bade07bbda0e2491d298 with Python 3.14. The import-audit suite completed with 287 passes and one Windows-only skip.
I also ran the classifiers on the same full source tree. The exact parent fffb30ef5b stopped at the 256-combination limit. The PR completed with the default limit and produced 21,086 stub entries, 2,602 marked partial. The complete sorted provider, NID, and name mapping and the partial set were byte-identical to the parent with only its limit raised to 32,768.
|
Test report: Setup
Result
The import totals match the ones in the PR description, from a second host. Not checked: AI-assisted test report. |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
The one failing check, The same failure shows up on other PRs. Of the 20 completed macOS relinker jobs I found on other PRs between 2026-11-27 22:07 and 2026-11-28 01:50 UTC, 12 failed this test with the same error and 8 passed. #27860 fixes it and is still open. Its body links a native macOS run where the replay tests pass, including the descendant-cleanup case that failed here ( Not covered: the scan read only the most recent completed AI-assisted: yes. Claude Code read the job log, scanned the other PRs' macOS jobs and drafted this comment. |
|
Validation datapoint on the real tree (current main 6100e07, linux x86_64): with this PRs tools/import_audit.py, the source scan of the shipped libkernel completes end-to-end — source_stubs finishes with 36 stub entries instead of dying at the 256-combination abort. PollDescriptors is the exploding function here, same as the report in #28157. One coverage note while comparing approaches: pruning once a counterexample variant appears handles functions whose variants disagree, but a genuinely unconditional thrower wrapped in many independent host branches still needs exhaustive enumeration to prove the throw — that case can still hit the cap. Probably rare enough in practice not to matter; mentioning it only so the limitation is recorded. Independent of this PR I had prototyped a complementary angle on akkadbakkad89/AnyPS5 branch import-audit-branch-collapse before discovering this one: collapse branch groups whose alternatives are inert for the analysis (no calls, control flow or braces) before enumerating — those cases then stay exact rather than merely surviving — plus a conservative per-function degrade with a loud stderr warning when genuinely distinct variants still overflow. Happy to re-propose it on top of this PR once yours lands, or drop it if you would rather fold the idea in here. |
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
|
Tested PR #27805 ( Results (
|
…as a stub always_stub_calls read every preprocessor combination of each function that might reach NotImplemented_nid_no_patch before checking whether all of them call a stub. A helper that calls it only behind a condition, with more than 256 combinations, aborted the whole audit, although its first combination already shows it is not an always-stub helper. Since boykopovar#27260 libkernel's PollDescriptors is such a helper, so import_audit.py and audit_dump.py stop for every title. A combination with no call to a function that might reach a stub can never be satisfied, so reading stops there and the helper is left out, as the full read would have decided. Every body is still parsed first, so an unmatched #if in a later overload still fails the audit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c916d39 to
b8817a6
Compare
ligmaSec
left a comment
There was a problem hiding this comment.
The import-audit suite ran 288 tests, with 286 passes and two skips. The added cases verify that identifying a stub stops branch expansion for that helper while an unmatched conditional in a subsequent overload still fails the audit.
AI-assisted: yes.
Plyxen
left a comment
There was a problem hiding this comment.
I read the diff at b8817a6f73. Windows 11, Python 3.13.7, merged into main at c1593e4e1dd together with other open PRs (so not an isolated tree).
tools.tests.test_import_audit: 290 tests pass (3 skipped).- Control (only this PR's change to
tools/import_audit.pytaken out):test_guarded_stub_helper_host_branches_do_not_abort_source_classificationfails.
Not checked: the speed over the whole source tree.
AI-assisted: yes (Claude Code)
What
On current
main,tools/import_audit.py, and sotools/audit_dump.py, stop before they print a report:The source scan does not depend on the title, so this happens for any title. The function is libkernel's
PollDescriptorsinSocket/src/Udp.cpp. Since #27260 it callsNotImplemented_nid_no_patchbehind a condition. Soalways_stub_callscounts it among the functions that might reach a stub, and reads every combination of its preprocessor branches before checking any of them. It has 12,288 combinations, and the limit stops the read at 257. #13002 skips helpers that cannot reach a stub at all; this one can, but not in every combination.A helper is an always-stub helper only if every combination calls, unconditionally, the stub or another such helper. All of those are among the functions that might reach a stub. So once one combination calls none of them, the helper can never qualify, whatever the other combinations are.
always_stub_callsnow stops reading there and leaves the helper out. Every body of the helper is still parsed first, so an unmatched#ifin a later overload still fails the audit.A helper whose combinations all call such a function is still read in full, and it still fails at the limit (
test_relevant_helper_host_branches_keep_the_variant_limit).Tested
Windows 10 (10.0.19045), Python 3.11. I tested on
a078f08ea8and then rebased ontofffb30ef5b. That main still fails with the error above, and none of its new commits change the audit's files. On it,test_import_audit.pypasses, and the real-tree result is identical to the raised-limit result (21,086 stubs, 2,602 partial).New tests.
test_guarded_stub_helper_host_branches_do_not_abort_source_classification: a helper with a guarded stub call, an unconditional call to a function that is not a stub, and 9#ifdefblocks (512 combinations). The code onmainfails it with the error above. With this change, the export that calls the helper ispartial. The code onmaingives the same answer for the same helper with 7 blocks (128 combinations).test_unmatched_if_in_a_later_helper_overload_still_fails: the first overload stops the read, and the second has an unmatched#if. The audit still fails with#if without a matching #endif, as onmain.Breaking each part (each mutant run against the whole
test_import_audit.py; the unchanged commit passes before and after):main)test_guarded_stub_helper_host_branches_do_not_abort_source_classification(the limit error)test_unrelated_helper_host_branches_do_not_abort_source_classificationtest_guarded_exports_are_partial_and_unconditional_ones_are_stubstest_unmatched_if_in_a_later_helper_overload_still_failsSame answers on the real tree.
source_stub_classesoncore/libs/prx, with the code onmainand with this change:main8e5fd06023, the lastmainbefore #27260a078f08ea8(currentmain)ad768c99cc(#27260's head)A title.
tools/audit_dump.py --windowson PPSA38500 exits 2 with the error above onmain, and exits 0 with this change (650 implemented, 41 partial, 0 stub, 0 absent, 190 module imports).Tools tests. I ran each
tools/tests/test_*.pyfile as its own script, on this change and ona078f08ea8: 161 files. On both sides onlytest_forced_include_paths.pyfails, with exit code 2, because it needs--cmake,--compiler,--generatorand--make-program.tools/select_tests.py explainselects 1,214 tests: 870 registered fromtools/, 342 entries whose executables are not built in my graph's tree, and 2 replay fixtures. I did not run those 344; this change touches only Python files.Overlap.
tools/pr_overlap.pycould not merge #27628 intomain. By hand, #27628 changesresolveinimport_audit.pyand one test near line 3095, notalways_stub_calls. It found no overlap with the other open PRs that change these files.Not covered: Linux and macOS. A helper whose first 256 combinations all call a function that might reach a stub still fails at the limit.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Summary by CodeRabbit