Skip to content

Commit

Permalink
tmp: Add EXPENSIVE_CHECKS wrapper around fsm_exec's is_isdfa check.
Browse files Browse the repository at this point in the history
Normally this doesn't matter, because the expected API use is based on
code generation rather than heavily using `fsm_exec`, but we are
calling fsm_exec to check that the combined DFAs still match all of
their original regexes. This is very expensive. (It similarly gets
very cumbersome during fuzzing.)

A better way to address this long-term is tracking on the FSM whether
it's result of fsm_determinise (and optionally fsm_minimise), and
updating that info to indicate that it reverted to an NFA if any
other operations modify the FSM states/edges. That's outside the scope
of this PR though.
  • Loading branch information
silentbicycle committed Oct 14, 2024
1 parent 6e9b7f1 commit f2ac082
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libfsm/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ fsm_exec(const struct fsm *fsm,

/* TODO: pass struct of callbacks to call during each event; transitions etc */

#if EXPENSIVE_CHECKS
if (!fsm_all(fsm, fsm_isdfa)) {
errno = EINVAL;
return -1;
}
#endif

if (!fsm_getstart(fsm, &state)) {
errno = EINVAL;
Expand Down

0 comments on commit f2ac082

Please sign in to comment.