From 05ef50d08aa8d78e0346d8c60e44a03d1e6ffb40 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 Apr 2018 00:25:31 +0000 Subject: [PATCH] Fix an unreachable branch associated with stack overflow in the LEMON-generated parser. FossilOrigin-Name: e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index fbd61bf9a3..70324922b1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovements\son\sthe\smain\sloop\sof\sthe\sLEMON-generated\sparser. -D 2018-04-21T22:40:08.247 +C Fix\san\sunreachable\sbranch\sassociated\swith\sstack\soverflow\sin\sthe\nLEMON-generated\sparser. +D 2018-04-23T00:25:31.966 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439 @@ -1645,7 +1645,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 33892e2a243865f73e6c6e7cecce3c6eb4bb95db4a3d9d86d146c8064feb92fd -F tool/lempar.c 01f28a4d245f0ea480fab1147c1244fe50434cea924ce258b3e8570a6340a0d3 +F tool/lempar.c bf7db78e7213f1d51516710483eab506fd52bf632c7abfb3e2e9b885c90c03e1 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1725,7 +1725,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dcf2bafc159179859b91ffea3a4ebd70b5ca6de9e1d515eaf9afde8cfff26c6c -R 30c687ea8cbf9562ea971a83f0b60716 +P fec1ebadeb9d6b55b19a1c159c543fd7ae67b3307c4caee4d2541bd783630e23 +R ab0db3a54428a9f0725860ac9691f760 U drh -Z 5f81242a2fad2cc1a6991b9a8c5f4a01 +Z 527d3a0e1a395ba78e820e4cf3bc4ff9 diff --git a/manifest.uuid b/manifest.uuid index febf97a27e..cf70910739 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fec1ebadeb9d6b55b19a1c159c543fd7ae67b3307c4caee4d2541bd783630e23 \ No newline at end of file +e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index d2b700a8cf..885cefe143 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -747,13 +747,19 @@ static YYACTIONTYPE yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - return YY_ACCEPT_ACTION; + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - return YY_ACCEPT_ACTION; + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; } yymsp = yypParser->yytos; } @@ -930,14 +936,8 @@ void Parse( #endif break; }else if( yyact==YY_ACCEPT_ACTION ){ - /* YY_ACCEPT_ACTION also happens on a stack overflow. We distingush - ** the two cases by observing that on a true accept, there should be - ** a single token left on the stack, whereas on a stack overflow, - ** the stack has been popped (by yyStackOverflow()) to be empty */ - if( yypParser->yytos > yypParser->yystack ){ - yypParser->yytos--; - yy_accept(yypParser); - } + yypParser->yytos--; + yy_accept(yypParser); return; }else{ assert( yyact == YY_ERROR_ACTION );