Skip to content

Match_Timeout_Repetition_Throws(engine: NonBacktracking) timing out #65991

@stephentoub

Description

@stephentoub

This outer loop test is now running for a very long time and eventually the test suite times out. I expect this is due to 83e5cbc, and that it's doing exactly what it tried to do, which is keep execution in the inner loop as long as possible. That would mean, however, that we wouldn't exit out into the outer loop frequently enough to hit the timeout check:

// Now run the DFA or NFA traversal from the current point using the current state.
int finalStatePosition;
int findResult = currentState.NfaState is not null ?
FindFinalStatePositionDeltas<NfaStateHandler>(builder, input, ref i, ref currentState, ref matchLength, out finalStatePosition) :
FindFinalStatePositionDeltas<DfaStateHandler>(builder, input, ref i, ref currentState, ref matchLength, out finalStatePosition);
// If we reached a final or deadend state, we're done.
if (findResult > 0)
{
return finalStatePosition;
}
// We're not at an end state, so we either ran out of input (in which case no match exists), hit an initial state (in which case
// we want to loop around to apply our initial state processing logic and optimizations), or failed to transition (which should
// only happen if we were in DFA mode and need to switch over to NFA mode). If we exited because we hit an initial state,
// find result will be 0, otherwise negative.
if (findResult < 0)
{
if ((uint)i >= (uint)input.Length)
{
// We ran out of input. No match.
break;
}
// We failed to transition. Upgrade to DFA mode.
Debug.Assert(currentState.DfaState is not null);
NfaMatchingState nfaState = perThreadData.NfaState;
nfaState.InitializeFrom(currentState.DfaState);
currentState = new CurrentState(nfaState);
}
// Check for a timeout before continuing.
if (_checkTimeout)
{
DoCheckTimeout(timeoutOccursAt);
}

cc: @olsaarik

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions