Repository navigation
Reject a nullptr in the FSM solver's state register and transition logic - #695
Merged
Merged
Conversation
solve_fsm checked that the state register and the transition logic are not empty, but not what they contain. A nullptr in the state register, e.g. a None passed from Python, was dereferenced while building the next-state functions and crashed HAL. A nullptr in the transition logic did not crash, but was only caught four levels down, by the subgraph function cache, with an error that did not say where it came from. Check both lists up front and name the index of the nullptr in the error, as is already done for the nets of an output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AriKHaji
self-requested a review
November 27, 2026 14:32
AriKHaji
approved these changes
Nov 27, 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.
Problem
solve_fsmchecks that the state register and the transition logic are not empty, but not what they contain.A nullptr in the state register crashes HAL. This happens, for example, when a
Noneis passed from Python.generate_state_bfsdereferences each flip-flop while building the next-state functions, so this segfaults no matter where in the list the nullptr is:A nullptr in the transition logic doesn't crash, but the error doesn't point to it. It is only caught four levels down, when the subgraph function cache is built:
Change
solve_fsmchecks both lists up front, after the existing checks for empty lists. It returns an error that names the list and the index of the nullptr, the same way it already reports a nullptr net in an output:Testing
check_invalid_configurationnow passes a nullptr at the start and at the end of each list, and checks that the error names the right index.runTest-solve_fsmsegfaults.fsmexample with the debug build: aNoneat the start or end of the state register, or of the transition logic, now gives the errors above instead of crashing. The valid configuration still solves.solve_fsm.cpp, its tests and the changelog. The merged result builds and passes all 11 tests.🤖 Generated with Claude Code