tools: report static stand-in export coverage in compat_report #3457
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3457
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3455"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-11-29 13:11 UTC · original
Leyukaka:tools-compat-import-coverage→main· +547 −54 · 6 files · 7 commits · merged 2026-11-29 14:16 UTCtools/compat_report.pylabelled each import with a candidate module route only, andstub_providerswas the constant 0. It now also looks each import up in the repository stand-in sources (newtools/standin_exports.py) and reports whether the stand-in declares that export and how the reviewed body behaves. The lookup reads the.deffiles, the directextern "C" __declspec(dllexport)lines ofsrc/startup_stubs/d3d12_xs_device.cppand of the files it includes with a quoted#include(first level), and the thunk table insrc/xgameruntime_shim.cpp. The image is still only read as PE directory data.New fields
Per import row:
export_status:implemented,trap,absentorunmeasured.implemented/trap: the export is declared and its target is in the reviewed table instandin_exports.py(or, for the runtime shim, the state column of its thunk table). Atrapbody in that table reachesx2w_trap::fireon the default path (no permissive or trap-override variable set); seven of the 21 were re-read on711f2227.absent: the module has a stand-in export table and the name is not in it. An ordinal isabsentonly for a module whose.defgives every export an ordinal (xmem and gameinput today).unmeasured: everything else, including declared exports with no reviewed target and modules without a stand-in.standin_module,standin_kind(shim,startup,fixture_only),export_sourceandbehavior_source(path:line, or null).The reviewed table holds 56 export names per source file (35
implemented, 21trap), not line numbers. The line inbehavior_sourceis resolved when the catalog is built, from theextern "C" ... name(...) {definition or theX2W_TRAP_EXPORT(n, name)line. A reviewed name with no such line in its file raisesValueError.Section and summary:
export_coverage_version: 1.summary.export_status_countsandsummary.imports_resolved_and_implemented(theimplementedcount).summary.stub_providersis now the number of distinct stand-in modules with at least onetraprow.Markdown: one summary row per status, an
Imports resolved and implemented (static)row, and anExport statuscolumn in both import tables.Behaviour changes on existing inputs
generated_by.versiongoes from 1 to 2.scopetext is replaced. It now states that runtime loader resolution, provider selection, ABI compatibility and call success are unchecked.Stub providers: 0.is gone; the scope text followsResolution: not checked., and the count stays in the existingStub providerstable row.gdk_shim_coverage.read_defis now a wrapper over the newread_def_exports, whichstandin_exports.pyalso uses. It raisesValueErroron a malformed or duplicate.defline, and on a missing or emptyEXPORTSsection, where it used to skip such lines. It also decodes strict UTF-8 (the olderrors="replace"is gone). On the checked-in.deffiles the GDK matrix JSON (--exports [] --repo .) is byte-identical between the base and this branch.pe_inventory.import_tablesgains a keyword-onlytyped_symbols(default off, so other callers are unchanged).Test
On
711f2227(the branch includesmainc3cae611, merged indb5334bf),devpreset configured with-DX2W_WITH_OPUS=OFF:1/1 passed.
python -I -B tests/compat_report_check.pyexits 0.check_standin_exportscomputes each expectedpath:lineinstead of holding it:direct_export_sourcefinds the direct-export definition with its own regex,def_export_sourcereads the.defentry throughread_def_exports, and the twobehavior_sourcevalues come from_reviewed_sources.grep -nE ':[0-9]+' tests/compat_report_check.pymatches onlybuf[0:2] = b"MZ".Mutations on
711f2227, each restored afterwards:src/startup_stubs/d3d12_compute_dispatch.inlmovesx2w_d3d12_compute_censusfrom 1232 to 1233: the test still passes.src/startup_stubs/d3d12_compute_dispatch.inl:1232: the test fails with anAssertionErrorat the row comparison.XMemTransferMemorysetsERROR_NOT_SUPPORTEDand returnsFALSEwithout firing a trap. It is not in the reviewed table, so it reportsunmeasuredandxmem.dlldoes not count towardstub_providers; the fixture imports it and expects that row.Mutations on
469b8e4a(base77d1ba4d), each restored afterwards:GameInputCreatein the reviewed table set tosrc/startup_stubs/xg_xs.cpp: the test fails withValueError: src/startup_stubs/xg_xs.cpp: missing reviewed export 'GameInputCreate'.line = 1forced in_reviewed_sources: the test fails incheck_reviewed_sourceswithAssertionError: ('XMemAlloc', 'src/xmem_shim.cpp:1').On
beb33721(tests only),ctest --preset dev --no-tests=error -R '^compat_report'passes 1/1. It adds six cases that reach the threeraisestatements ofread_def_exports: two ordinals on one line, a malformed line, a duplicate name, a duplicate ordinal, a missingEXPORTSsection and an empty one. Replacing eachraisewith a skip makes one of its cases fail, and removing the duplicate-name or the duplicate-ordinal check makes that case fail.On
469b8e4a, where the table still held 57 names, all 57 resolved to their definition line, and none of the 57 resolved lines differed from the value that was hard-coded before that commit.Measured on the earlier head
7af897ad(line numbers are those of that commit), whereconditional_import_pathsandpe_compat_report_cli_checkalso passed:returnafter the own-fileyield fromin_direct_exports_with_includes(tools/standin_exports.py:152), so included files are no longer read: the test fails attests/compat_report_check.py:318, incheck_standin_exports, onexport_status_counts.if attached:replaced byif False:inread_def_exports(tools/gdk_shim_coverage.py:77), soName@Nis no longer split: the test fails attests/compat_report_check.py:353, incheck_def_exports, onFoo@4.Not covered
implemented,trapandunmeasuredare a static reading of the sources. Nothing is loaded or called, and the row'sresolutionstaysnot_checked.check_reviewed_sourceschecks that each reviewed name appears on its cited line, not that the line is a definition. Definition-only matching rests on the two regexes instandin_exports.py.behavior_sourcevalues incheck_standin_exportscome from the tool's own_reviewed_sources;check_reviewed_sourcesis the only independent check on them.unmeasureduntil it is added to the reviewed table. A stub that refuses without firing a trap (XMemTransferMemory) has no label of its own and staysunmeasured.d3d12_xs_device.cppincludes five files that hold direct exports. Only one export, fromd3d12_compute_dispatch.inl, is tested end to end; the other four rest on reading the include lines. Second-level includes are not followed; nothing needs them today.unmeasured.tools/gdk_knowledge_report.pyhas its ownEXPORTShandling, which is not changed here.EXPORTScase shares itsraisewith the missing-section case and was not isolated by a mutation.read_def_exports(reserved name, repeated flag,NONAMEwithout an ordinal, ordinal outside 1..65535, text beforeEXPORTS) and the strict UTF-8 decoding have no error case.@JohnConnorNPC on GitHub · 2026-11-29 13:40 UTC · original
Review of head
beb33721. Its merge-base is77d1ba4d.git merge-tree --write-tree origin/main beb33721againstmain4b0586d4exits 0. I rantests/compat_report_check.pywith Python 3.13 on Linux, at the head and on a trial merge withmain.Why CI is UNSTABLE:
Run platform-independent Python checks on Linuxfails in this PR's own test. The job log hasFAILED: tests/compat_report_check.py, fromcheck_standin_exportsatassert [tuple(row[field] for field in fields) for row in routing["imports"]] == [(AssertionError). It is the only failing group in that job. The other jobs passed.compat report synthetic checks passed, exit 0.main17b662a2, it fails the same way as CI (exit 1). The tool reportsx2w_d3d12_compute_censusatsrc/startup_stubs/d3d12_compute_dispatch.inl:1199, and the test expects:1126.mainthat line has moved twice since this PR's base:grep -n 'x2w_d3d12_compute_census('gives 1126 at77d1ba4d, 1199 at17b662a2and 1232 at4b0586d4. The edits came from thepacked_d16_xmanifest commits and the native-compute-bindings merge.MUST
check_standin_exportshard-codes line numbers in live repository sources. They ared3d12_compute_dispatch.inl:1126,xmem_shim.cpp:84,xg_xs.cpp:508, andxmem_shim.def:3/:4andxg_xs.def:4. Any edit above one of those lines makes the Linux job fail on every open PR. That is happening now.469b8e4astopped pinning these numbers in the reviewed table, but the test's expected rows still pin them. A suggested fix is to compute each expectedpath:linein the test by finding the definition or.defline in that file, the waycheck_reviewed_sourceschecks the cited line. Keep thepathpart and the status columns literal. A rebase that only updates1126would go red again on the next edit to that file.NIT
XMemTransferMemoryis in the reviewed table astrap, but its body (src/xmem_shim.cpp) setsERROR_NOT_SUPPORTEDand returnsFALSE. It never callsx2w_trap::fire. Because of that row,xmem.dllcounts towardstub_providers. I compared every othertrapentry against its body: each one firesx2w_trap::fireunless the module's permissive variable is set, directly or throughaccept()inchad.cpp. Either document thattrapincludes refusal stubs, or give refusal stubs their own label.Checked: the 57 reviewed names all resolve to
extern "C" … name(…) {orX2W_TRAP_EXPORTlines on the merged tree. None of the 35implementedbodies callsx2w_trap::fire.import_tables(..., typed_symbols=False)keeps the old#Nstrings for other callers. The diff has no binary files and adds no title-specific inputs.Not merged because of MUST 1.
AI-assisted.
@Leyukaka on GitHub · 2026-11-29 13:53 UTC · original
New head
711f2227. The branch now includesmainc3cae611(mergedb5334bf).c68ffa88:check_standin_exportsno longer holds a line number of a live source. Each expectedpath:lineis computed, with the path and the status columns still literal (tests/compat_report_check.py:370-385).direct_export_source(:324) finds theextern "C" __declspec(dllexport)definition with its own regex,def_export_source(:333) reads the.defentry throughread_def_exports, and the twobehavior_sourcevalues come from_reviewed_sources.711f2227:XMemTransferMemoryis removed from the reviewed table (tools/standin_exports.py:16-32), so it reportsunmeasuredwith a nullbehavior_source, andxmem.dllno longer counts towardstub_providers.trapkeeps one meaning, a body that reachesx2w_trap::fireon the default path, and refusal stubs get no label of their own. Seven of the 21 remainingtrapbodies were re-read on this head (acphal, chad, xapu, xg_xs); all seven fire when no permissive or trap-override variable is set. The fixture importsXMemTransferMemoryand expects theunmeasuredrow (tests/compat_report_check.py:349,:379-380). The table now holds 56 names: 35implemented, 21trap.Measured on
711f2227,devpreset configured with-DX2W_WITH_OPUS=OFF:ctest --preset dev --no-tests=error -R '^compat_report': 1/1 passed.python -I -B tests/compat_report_check.py:compat report synthetic checks passed, exit 0.src/startup_stubs/d3d12_compute_dispatch.inlmovesx2w_d3d12_compute_censusfrom 1232 to 1233; the test still passes.src/startup_stubs/d3d12_compute_dispatch.inl:1232: the test fails with anAssertionErrorat the row comparison.grep -nE ':[0-9]+' tests/compat_report_check.pymatches onlybuf[0:2] = b"MZ".Not covered: the two expected
behavior_sourcevalues come from the tool's own_reviewed_sources, so that column compares the tool with itself. The only independent check on it ischeck_reviewed_sources(tests/compat_report_check.py:303), which requires the cited line to contain the name.@JohnConnorNPC on GitHub · 2026-11-29 14:16 UTC · original
Re-review of head
711f2227(new sincebeb33721: merge ofmaindb5334bf, thenc68ffa88and711f2227).git merge-tree --write-tree origin/main 711f2227againstmain0ed385dcexits 0. I rantests/compat_report_check.pywith Python 3.13 on Linux at the head and on that trial merge, plus five mutations of the merged tree.Earlier findings
path:line(direct_export_source,def_export_source). The path and status columns stay literal.compat report synthetic checks passed, exit 0. Trial merge: same, exit 0. On thatmain,x2w_d3d12_compute_census(is at line 1250 (git grep -n), so the old literal:1126would have failed again.d3d12_compute_dispatch.inl, the test still passes (exit 0). With a comment line added aboveEXPORTSinsrc/xmem_shim.def, it also still passes (exit 0).f"{path}:{line + 1}"in_direct_exports):AssertionError, exit 1. The tool reports a.defexport one line late:AssertionError, exit 1. So the computed expectations are not just copies of the tool's own output.behavior_sourcestill comes from_reviewed_sources, as your reply says. If_reviewed_sourcesreports lines one late,check_reviewed_sourcesfails (AssertionError: ('XMemAlloc', 'src/xmem_shim.cpp:85'), exit 1). So that column has an independent check.XMemTransferMemoryastrap): fixed. It is out of the reviewed table and the fixture expectsunmeasured. Putting thetraprow back fails the test (AssertionError, exit 1). No tool source still namesXMemTransferMemory(grep -cgives 0 instandin_exports.py,gdk_shim_coverage.pyandcompat_report.py).New findings: none.
CI on
711f2227is green, includingRun platform-independent Python checks on Linux. There are no reviews or change requests. The diff has no binary files and no title-specific inputs.Merging.
AI-assisted.