Skip to content

Fix #934: segfault when substituting a SubTree node#1083

Merged
facontidavide merged 2 commits intomasterfrom
fix/934-subtree-substitution-segfault
Feb 1, 2026
Merged

Fix #934: segfault when substituting a SubTree node#1083
facontidavide merged 2 commits intomasterfrom
fix/934-subtree-substitution-segfault

Conversation

@facontidavide
Copy link
Collaborator

Summary

  • Adds null-check after dynamic_cast<SubTreeNode*> in XMLParser::PImpl::recursivelyCreateTree before calling setSubtreeID
  • When a SubTree node is substituted (e.g., with a test node), the replacement is not a SubTreeNode, so the cast returns nullptr causing a segfault

Fixes #934

Test plan

  • Added Substitution.SubTreeNodeSubstitution test that reproduces the segfault by substituting a SubTree node
  • All 309 tests pass (308 existing + 1 new)

🤖 Generated with Claude Code

When a substitution rule replaced a SubTree with a TestNode,
dynamic_cast<SubTreeNode*> returned nullptr but setSubtreeID was
called unconditionally, causing a null pointer dereference. Add a
null-check so setSubtreeID is only called on actual SubTree nodes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/934-subtree-substitution-segfault

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.99%. Comparing base (e0684b0) to head (10b9ae5).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1083      +/-   ##
==========================================
+ Coverage   65.90%   65.99%   +0.09%     
==========================================
  Files         225      225              
  Lines       12727    12738      +11     
  Branches     1186     1186              
==========================================
+ Hits         8388     8407      +19     
+ Misses       4289     4281       -8     
  Partials       50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Use explicit != nullptr comparisons for pointer-to-bool conversions
flagged by clang-tidy.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@facontidavide facontidavide marked this pull request as ready for review February 1, 2026 19:39
@facontidavide facontidavide merged commit 25407ad into master Feb 1, 2026
13 checks passed
@facontidavide facontidavide deleted the fix/934-subtree-substitution-segfault branch February 1, 2026 19:39
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.

Segmentation fault when substituting subtree

1 participant