mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
glr2.cc: fix calling conventions for yyexpandGLRStackIfNeeded
This test fails: 748: Incorrect lookahead during nondeterministic GLR: glr2.cc It consumes lots of stack space, so at some point we need to expand it. Because of Boolean logic mistakes, we then claim memory-exhausted (first error). Hence we jump to cleaning the stack (popall_), calling all the destructors, and at some point we crash with heap-use-after-free (second error). This commit fixes the first error. Unfortunately, even though we now do expand the stack, we crash again with (another) heap-use-after-free, not addressed here. Eventually, we should make sure popall_() properly works. * data/skeletons/glr2.cc (yyexpandGLRStackIfNeeded): Return true iff success (i.e., memory not exhausted).
This commit is contained in:
@@ -1449,7 +1449,7 @@ class state_stack {
|
||||
/** Returns false if it tried to expand but could not. */
|
||||
bool
|
||||
yyexpandGLRStackIfNeeded() {
|
||||
return spaceLeft() < YYHEADROOM && yyexpandGLRStack();
|
||||
return YYHEADROOM <= spaceLeft() || yyexpandGLRStack();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1471,7 +1471,7 @@ class state_stack {
|
||||
#else
|
||||
bool yyexpandGLRStackIfNeeded ()
|
||||
{
|
||||
return spaceLeft () < YYHEADROOM;
|
||||
return YYHEADROOM <= spaceLeft ();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1895,7 +1895,7 @@ public:
|
||||
]b4_namespace_ref[::]b4_parser_class[& yyparser;
|
||||
|
||||
void yyreserveGlrStack() {
|
||||
if (yystateStack.yyexpandGLRStackIfNeeded ())
|
||||
if (!yystateStack.yyexpandGLRStackIfNeeded ())
|
||||
yyMemoryExhausted();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user