Open MarkusQ opened 12 years ago
Forgot to state that this was tests under maglev 1.0.0 (ruby 1.8.7) (2011-10-31 rev 1.0.0-27184)[Linux x86_64] installed with rvm on Linux 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux and my spelunking in search of the cause was done on master at fd5a1532db2dcb25694962a079d317e7e5607bc5.
Unfortunately, that fix doesn't work. I think problem is rParenLexPop being called at the parser level vs the pushes being done at the lexer level. In this case, we've got p []
.
The sequence SHOULD be something like:
[
in lexer.command_args
.open_args
.command_args
.]
(preferably in lexer).but it is interleaved:
[
in lexer.command_args
open_args
command_args
.This is because of the way that lalr grammars pull from the lexical stream and then choose the correct grammatical production to match it to. Turning on ytrace + debugCmdArg shows the interleave happening.
I'm going to double check to make sure that this doesn't happen in MRI. It looks like it might, but their code isn't checking for overflow.
I think my analysis is wrong because of the overly clever code in BitStack using the same word to record both the stack and the depth.
I still think this is the problem. The stack value is correct, but the depth is not. It needs to be popped AFTER the restore in order to have the correct value. Interleaving is the problem. I don't know how to fix this with the current architecture, other than, possibly, to remove the depth bitfield entirely.
In gammar.y, rParenLexPop is used to pop level off ps->cmdarg_stack, but this does not get called in all the cases it should, allowing levels to accumulate on the stack.
This prevents several gems from compiling, and may be silently causing other issue due to improper parsing.
The simplest example I've come up with is:
which produces the error:
I suspect (but this is only a guess) that the correct fix would be to
with something like:
around line 1850 of grammar.y