New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test case crashes ocamllex #8026
Comments
Comment author: administrator
There are two bugs here, first the backtrace one, which I will not
To my surprise this is a design/parsing bug. In fact your << lexemes >> rule is not well formed the correct code is << \epsilon >> (ie nothing is not a valid ocamllex regular expression) At the moment the parser interpret your code as You can check the parser view of your code by swapping your two lexer Then the rest of the ocamllex is not prepared to a lexer definition As a conclusion you indeed discovered a bug (thank you for reporting All the best, --Luc |
Comment author: administrator ocamllex bug: Fixed by Luc on 2003-02-22 |
Original bug ID: 1554
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
The shell dialogue below shows that there is an input file that
crashes ocamllex. The ocamllex version in question was built from
fresh CVS sources this morning.
The shell dialogue also shows that in this case, ocamllex crashes when
it tries to compute a stack trace.
Then we go on to try ocamllex from the ocaml 3.06 distribution. It
works fine.
Then we show that the same problem was present with a version built
from November 2002 CVS sources, but a stack trace can be produced. I
wrote down some thoughts about the stack trace after the shell dialogue.
lobus:/huge/tim/unhacked-ocaml-anon-cvs> printenv OCAMLRUNPARAM
-b
Here are some lines from my copy of the November, 2002 version of
lexgen.ml, with a "^" inserted below character 38 of line 1071:
let translate_state shortest_match tags chars follow st =
let (n,(_,m)) = st.final in
if MemMap.empty = st.others then
Perform (n,do_tag_actions n tags m)
^
else if shortest_match then begin
if n=no_action then
Shift (No_remember,reachs chars follow st.others)
else
Perform(n, do_tag_actions n tags m)
end else begin
Shift (
(if n = no_action then
No_remember
else
Remember (n,do_tag_actions n tags m)),
reachs chars follow st.others)
end
One hypothesis is that the stack trace is garbage, since it's
complaining that Array.get is returning an out-of-bounds result but it
gives a pointer to a place that is not a call to Array.get.
Another hypothesis is that the problem happened in the array reference
to env.(n) at the end of do_tag_actions, and the compiler decided to
inline do_tag_actions, and the code that generates stack traces isn't
kind enough to insert stack frames for inlined subroutines.
The problem may have been caused by me putting an empty regexp in the
lex.mll file. This is a sensible thing to do, but the documentation
for ocamllex says it is illegal. Nevertheless it should not crash
ocamllex.
--
Tim Freeman
tim@fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D 7180 76DF FE00 34B1 5C78
The text was updated successfully, but these errors were encountered: