Draft
Fix segfault in cb_react_ruleset_nd when Rule arg is not a membrane#373
Conversation
…roxy When state_space.react_nd_set is called with a non-membrane argument (e.g. [] nil atom) as the Rule parameter, cb_react_ruleset_nd crashed with SIGSEGV because it unconditionally dereferenced rule_mem_proxy as an outer membrane proxy. The fix adds a LMN_IS_PROXY_FUNCTOR() guard before accessing the membrane. When rule_mem_proxy is not a proxy (e.g. []), rule application is skipped and an empty result list is returned, consistent with 'no rules to apply' semantics. Also adds a regression test to the statespace library test suite. Co-authored-by: okamura10 <130753425+okamura10@users.noreply.github.com>
Co-authored-by: okamura10 <130753425+okamura10@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix segmentation fault in priority rule execution
Fix segfault in cb_react_ruleset_nd when Rule arg is not a membrane
Feb 21, 2026
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.
state_space.react_nd_setcrashes with SIGSEGV when called with a non-membrane atom (e.g.[]) as theRuleargument, becausecb_react_ruleset_ndunconditionally dereferencesrule_mem_proxyas an outer membrane proxy without checking its functor type.Changes
src/ext/react_rule.cpp: Wrap therule_memextraction andapply_rules_in_rulesetscalls in aLMN_IS_PROXY_FUNCTOR()guard. Whenrule_mem_proxyis not an outer proxy (functor ≥ 3), rule application is skipped and an empty list is returned — semantically equivalent to "no rules to apply". All remaining cleanup (graph membrane removal,RetRulerelinking) is unaffected.test/library_check/testsuite/statespace/statespace.lmn: Add regression test case that callsstate_space.react_nd_set([], {a}, rules)and asserts the result is[](empty successor list, no crash).Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.