Conversation
lyplg_ext_parsed_get_storage() searches only the parsed extension instances of the module itself. However, top-level extension instances of a submodule are compiled into the main module's compiled extension array, so their parsed counterparts live in the submodule's parsed extension array and the lookup failed, hitting the assert. This could be triggered, for example, by a submodule top-level sx:augment-structure instance when printing the module tree with compiled nodes (LY_CTX_SET_PRIV_PARSED) or when resolving typedefs of extension instance children during compilation. Search the parsed extension arrays of all included submodules as a fallback.
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.
Closes: #2575
lyplg_ext_parsed_get_storage()searches onlyext->module->parsed->extsfor the parsed extension instance. However, top-level extension instances of a submodule are compiled into the main module's compiled extension array (mod_c->exts), while their parsed counterparts remain in the submodule'slysp_submodule::exts. For such instances the lookup fails and the unconditionalassert(extp)aborts the process.Reproducer
The same lookup is reached during compilation when children of a submodule extension instance resolve typedefs or groupings (e.g. an
sx:structurewith an internaltypedefplaced in a submodule), so the crash is not limited to printing.Fix
Search the parsed extension arrays of all included submodules as a fallback when the instance is not found in the main module's parsed extension array. The lookup semantics (first match by extension name) are unchanged.
Regression test
test_submodintests/utests/extensions/test_structure.cparses a module whose submodule contains a top-levelsx:augment-structureand prints its tree withLY_CTX_SET_PRIV_PARSED(which is whatyanglint -f treesets). Before the fix this asserts; with the fix theaugment-structuresection is printed correctly.