Repository navigation
detect include cycles in XMLParser::loadDocImpl - #1248
Open
aysha-afrah26 wants to merge 1 commit into
Open
aysha-afrah26 wants to merge 1 commit into
aysha-afrah26 wants to merge 1 commit into
Conversation
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.
<include path="..."/>tags are followed recursively byXMLParser::PImpl::loadDocImpl, but unlike SubTree instantiation, which rejects cycles through theancestorsset added for #979, nothing stops a file from being included again by one of its own descendants. A file that includes itself, or two files that include each other (for example a shared subtree library that pulls in the file using it), makescreateTreeFromFileload the same document over and over, keeping every copy alive inopened_documents, until the native stack runs out. Under ASan the process dies with a stack-overflow in tinyxml2 parsing beneathloadDocImpl, and in a release build it is a plain SIGSEGV the caller cannot catch, so a mistake in the XML takes down the whole executor instead of producing an error message. I noticed it while comparing the include path with the SubTree cycle check, and reproduced it with a self-including file of a few lines. The fix tracks the canonical paths of the files on the current include chain and throws aRuntimeErrorwhen a file is included by one of its own ancestors; entries are removed on the way back up, so diamond includes (the same file pulled in from two siblings) still load as before. The change stays inside the private PImpl, so there is no API or ABI change, and the two new tests ingtest_factory.cpp(CreateTreeFromFileWhichIncludesItself,CreateTreeFromFileWithIncludeCycle) abort with an ASan stack-overflow on master and pass with the fix.