it's me again, the guy who uses the lemon parser generator in his
project (http://www-csr.bessy.de/control/SoftDist/sequencer/).

I have found another problem in lempar.c. This one leads to crashes
(assertion failures) in my compiler, at least on 64 bit systems
(observed on Windows and Linux).

The failed assertion is at line 397 in lempar.c which reads:

  assert( pParser->yytos > pParser->yystack );

This is is function yy_pop_parser_stack. I searched for where this
function is used and found that in all cases except one there is a
condition that guarantees the above precondition is actually fulfilled.
The exception is at line 881 in function Parse where it says

        while( yypParser->yytos >= yypParser->yystack
            && yymx != YYERRORSYMBOL
            && (yyact = yy_find_reduce_action(
                        YYERRORSYMBOL)) >= YY_MIN_REDUCE
        if( yypParser->yytos < yypParser->yystack || yymajor==0 ){

Here, the loop condition is '>=', not '>'. I think the loop condition
should have '>'. Also, the if condition after the loop is dubious: I
think there should be an assertion after the loop:

        assert( yypParser->yytos >= yypParser->yystack );

since that appears to be an invariant; and the if-condition (that seems
to test whether the stack is now empty) should have '==':

        if( yypParser->yytos == yypParser->yystack || yymajor==0 ){

I attached a patch file that makes these changes. With the patch
applied, I get no more assertion failures (on Linux, awaiting
confirmation for Windows in the next days...).

BTW, it seems the bug only manifests when parsing fails, though not in
all such cases.


PS: Please include me in any replies as I am not subscribed to the list.
"Make it so they have to reboot after every typo." ― Scott Adams

Attachment: signature.asc
Description: OpenPGP digital signature

sqlite-users mailing list

Reply via email to