Skip to content

heap_index_census: read a carve index saved with a UTF-8 BOM (EGEN-HEAP-INDEX-BOM, DeepSeek3) - #6051

Open
evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/3-heap-index-bom
Open

evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/3-heap-index-bom

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tools/heap_index_census.py opened the carve index (/shaders/dxbc/index.json) as utf-8, so an index the user re-saved from an editor that writes a UTF-8 BOM raised Unexpected UTF-8 BOMinjson.load, fell into the ValueErrorhandler and stopped the whole census with oneERROR: cannot read the carve indexline and exit 2. The file is a user-facing copy, so this is the same BOM class already fixed inclassify_carve, world_index, gamedata_indexand others. Reading it asutf-8-sig` accepts both forms.

EGEN-HEAP-INDEX-BOM (found while working the small-tool bugs; posted as a finding in #5934).

Test

python -I tests/test_heap_index_census.py (no game files, no GPU):

  • Before (tools/heap_index_census.py from main), new test only:
    FAIL: test_cli_reads_a_carve_index_saved_with_a_bom —
    AssertionError: 2 != 0 : ERROR: cannot read the carve index next to ...\disasm: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
  • After: Ran 16 tests ... OK (the 13 existing tests plus the BOM test and two negative controls).

Notes

  • The negative-control commit pins that the new read still refuses an index that is not JSON or whose rows have no stage, with one cannot read the carve index line and exit 2, so the BOM acceptance does not widen into accepting a corrupt index.
  • No format or corpus claim is involved, so no docs/design.md contract row.
  • Kept to the one read at stage_index(); --json output stays utf-8 without a BOM, as the other tools write reports.

AI-assisted.

The census opened <work>/shaders/dxbc/index.json as utf-8, so an index a user
re-saved with a BOM fell into the ValueError handler and the whole run stopped
with "cannot read the carve index" and exit 2. utf-8-sig reads both forms.

(EGEN-HEAP-INDEX-BOM, DeepSeek3)
Without the utf-8-sig read the CLI stops with "ERROR: cannot read the carve
index ... Unexpected UTF-8 BOM" and exit 2; with it the census reads the same
one-shader folder it reads from a BOM-free index.

(EGEN-HEAP-INDEX-BOM, DeepSeek3)
…RROR line

Negative controls for the utf-8-sig read: it must accept a BOM, not a broken
index. Both cases keep exit 2 with a single "cannot read the carve index" line.

(EGEN-HEAP-INDEX-BOM, DeepSeek3)
@leozinhoszg

Copy link
Copy Markdown
Contributor

Tested b6555fa9 on Windows 11 Pro (26200), CPython 3.14.7, CPU only, no game files: pass.

  • python -I tests/test_heap_index_census.py: 16/16 pass. compileall and git diff --check are clean. Merged with heap_index_census: track scalar carry for descriptor addresses (D3D-329) #6063 (git merge-tree is clean): 20/20 pass.
  • Negative control: with main's tools/heap_index_census.py, only test_cli_reads_a_carve_index_saved_with_a_bom fails (2 != 0, Unexpected UTF-8 BOM). The two refusal tests pass on both trees, as the guards they are meant to be.

AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified at your head on main 561b65a: test_heap_index_census 16/16 (re-run) including the BOM round-trip and the two refusal cases, which produce exactly one ERROR line through the existing (OSError, ValueError, KeyError, TypeError) handler at heap_index_census.py:432 — asserted, not assumed. utf-8-sig is byte-identical for BOM-less input, so indexes without a BOM see no behavior change, and sampler_source_census inherits the fix via hic.stage_index. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants