Repository navigation
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I ran this against 20 projects (the 7 in One suggestion: when it does fire, the placeholder looks like an ordinary empty program in the L5X, so whoever opens the file can't tell a program was lost. Could the placeholder carry a description saying so, e.g. "acd-tools: this program's record could not be read"? Studio 5000 shows descriptions, so it would be visible where people actually look. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One corrupt program comps record aborts the whole project's export (
kaitaistruct.EndOfStreamError)Note: this patch touches the same file as 0004/0006/0007 and adds the
same
from loguru import logger as logimport each does. If applying morethan one of these to
acd/l5x/elements.pyat once, keep a single copy ofthat import line — see the top-level README's "Applying more than one
patch to the same file" note.
Symptom
raised from deep inside
RxGeneric.from_bytes()(via the generated Kaitaiparser reading an
AttributeRecord'slen_value-prefixed value), abortingthe entire project's export over a single program.
Root cause
One program's comps record (a real, named program — not a deleted/tombstone
record) has a corrupt extended-attribute length prefix partway through its
attribute list: at some
AttributeRecord, thelen_valuefield reads backas
16842752when only4054bytes remain in the buffer. This is a harddesync — once one length-prefixed field's length is wrong, there's no
reliable way to resync to where the next attribute actually starts, so
this can't be parsed correctly by looking further into the same record. No
second file with the same corruption shape was available to compare
against and confirm a specific misread offset.
This one comps record is read from two independent places:
ProgramBuilder.build(), to build theProgramelement itself._program_schedule_id(), called fromControllerBuilder.build()whilebuilding a
comment_id_to_programlookup used for resolving each Task'sscheduled-program list.
Both call
RxGeneric.from_bytes()on the same corrupt record and bothwould raise, so both needed the same treatment.
Fix
Wrap both call sites in
try/except Exception, logging a warning namingthe program and degrading gracefully instead of raising:
ControllerBuilder.build()'s program loop: on failure, still append aProgramfor that name, but as an empty placeholder (no routines, notags, no main/fault routine) instead of the fully-built one.
comment_id_to_programdict-comprehension (converted to anexplicit loop so each iteration can be individually wrapped): on failure,
just skip that program's entry — it won't be resolvable as any task's
scheduled program, which is a far smaller loss than failing the whole
file's export.
Suggested validation
Only one real-world instance of this exact corruption was available to
test against (see the top-level README's note on why no sample file is
attached). The fix is intentionally conservative — it only catches and
degrades at the two points that actually call into this record's parsing,
so it shouldn't mask unrelated bugs elsewhere in the codebase.
🤖 Generated with Claude Code