re2c icon indicating copy to clipboard operation
re2c copied to clipboard

mismatched YYBACKUP and YYRESTORE (again)

Open mejedi opened this issue 9 months ago • 11 comments

The generated state machine invokes YYRESTORE without calling YYBACKUP first (for certain inputs). It results in a subsequent crash since we are restoring with a bogus state.

Please let me know if the below assumptions are wrong

  • YYBACKUP must be executed at least once before YYRESTORE
  • $ rule fires when EOF is reached AND state machine is not in a final state AND could not reach final state via YYRESTORE.

Here's the reproducer (I'm on re2c 3.1):

/*!re2c

  re2c:eof = 0;
  re2c:yyfill:enable = 0;

  [A>]* ">" {}
  $ {}

*/

Please find the first 20 lines of the output below:

$ re2go repro.re  --no-generation-date -i  -o /dev/stdout | head -n 20
// Code generated by re2c 3.1, DO NOT EDIT.

{
	var yych YYCTYPE
	yych = YYPEEK
	switch (yych) {
	case '>':
		goto yy2
	case 'A':
		goto yy4
	default:
		if (YYLESSTHAN) {
			goto yy5
		}
		goto yy1
	}
yy1:
	YYRESTORE
	goto yy3
yy2:

mejedi avatar May 15 '24 18:05 mejedi