Skip to content

A list group overlay throws on an entry that is not a group - #717

Open
WhiskyTangoFawks wants to merge 3 commits into
Mutagen-Modding:devfrom
WhiskyTangoFawks:fix/list-group-stray-record
Open

WhiskyTangoFawks wants to merge 3 commits into
Mutagen-Modding:devfrom
WhiskyTangoFawks:fix/list-group-stray-record

Conversation

@WhiskyTangoFawks

@WhiskyTangoFawks WhiskyTangoFawks commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

GroupListOverlay<T>.Factory reads each entry of a list group (CELL, and each game's equivalent) as a group header. A major record in that position was read as a group and stepped by its content length. Once a length read 0, the loop stopped advancing and its location list grew until OutOfMemoryException, after about 80 s on Fallout 4.

It now throws a ModGroupsMalformedException naming the mod, with the record's type and FormKey in the message, and the same exception for a group shorter than its header. The objectType parameter is removed, since every caller passed ObjectType.Group.

PluginBinaryOverlay.ParseRecordLocations, which a cell or worldspace block overlay uses to find its sub-blocks, stepped by group length with no progress check, so a sub-block shorter than its header stalled the same way. It now throws the same exception. Only a group can trip the check, since a subrecord's or major record's total length always includes its header.

ListGroupOverlayTests builds the bytes from each game's GameConstants, for Oblivion, Fallout 3, Skyrim, Fallout 4 and Starfield. A stray record or a group shorter than its header in a list group, and a sub-block shorter than its header, all throw; an empty cell block still reads as one block. On the old code the throwing cases hang until out of memory rather than failing.

Left as they are:

  • The full import still skips a stray record in a list group silently.
  • Each game's Cell.ParseRecordLocations steps over a cell's children groups by length with no progress check, so a children group shorter than its header can still stall there.

WhiskyTangoFawks and others added 2 commits October 24, 2026 15:27
GroupListOverlay.Factory read every entry of a list group (CELL, and
each game's equivalent) as a group header and stepped by its length.
A record in that place was read as a group, stepped by its content
length, and once a length read 0 the position stopped moving, so the
location list grew until the process ran out of memory. A group whose
length is shorter than its header stalled the same way.

It now throws a RecordException naming the record type, as the overlay
of an ordinary group does, and a MalformedDataException for a group
too short to hold its header. Every caller passed ObjectType.Group, so
the parameter goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test moves to Core, beside the parse it covers, and runs for
Oblivion, Fallout 3, Skyrim, Fallout 4 and Starfield. Each builds the
list group with MutagenWriter and HeaderExport from that game's
GameConstants, and takes its ModKey from AutoData, in place of the
hand-written Fallout 4 plugin bytes. The parse runs under a 30 second
bound, so a parse that stops advancing fails the test instead of hanging
the suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WhiskyTangoFawks
WhiskyTangoFawks force-pushed the fix/list-group-stray-record branch from 6b218d6 to d198e53 Compare October 24, 2026 14:56

@Noggog Noggog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps by group length with no progress check, so a zero-length sub-block group can still stall there

Would be good to handle while we're "in the area". But if you want to do as separate PR, that's up to you

{
var majorMeta = package.MetaData.Constants.MajorRecordHeader(stream.RemainingMemory);
var formKey = FormKey.Factory(package.MetaData.MasterReferences, majorMeta.FormID, reference: false);
throw new RecordException(formKey: formKey, recordType: null, modKey: package.MetaData.ModKey, edid: null, message: "Unexpected type encountered when parsing group locations: " + majorMeta.RecordType);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModGroupsMalformedException seems more appropriate here?

Both list group throws, a record where a group belongs and a group shorter
than its header, now throw ModGroupsMalformedException naming the mod, as
review asked. The record's type and FormKey move into the message.

ParseRecordLocations, which a cell or worldspace block overlay uses to find
its sub-blocks, stepped by a group's length with no progress check. A
sub-block group shorter than its header stepped by 0 and grew its location
list until out of memory. It now throws the same exception.

Not run red: the old code does not fail these tests, it loops until out of
memory, and the change is built and tested by CI rather than locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WhiskyTangoFawks

Copy link
Copy Markdown
Contributor Author

Switched both list group throws to ModGroupsMalformedException, and handled the sub-block stall here: ParseRecordLocations now throws on a sub-block shorter than its header. ListGroupOverlayTests covers it for each game. Each game's Cell.ParseRecordLocations has the same gap for a cell's children groups; I've left that out, as noted in the description.

This branch has not been deployed

No deployments
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.

2 participants