Skip to content
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

segmentation fault in ocamllex-generated program #4517

Closed
vicuna opened this Issue Mar 3, 2008 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Mar 3, 2008

Original bug ID: 4517
Reporter: @mjambon
Assigned to: @maranget
Status: closed (set by @xavierleroy on 2010-04-29T12:25:58Z)
Resolution: fixed
Priority: normal
Severity: crash
Version: 3.10.1
Fixed in version: 3.11+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @yakobowski

Bug description

Program below ends with a segfault. Haven't found a shorter version.

Small variations in the program can make it work or not (ending with an exception would be fine). The behavior appears to be the same for a given program regardless of the ocaml version (3.09.3 or 3.10.1). Same behavior is observed with bytecode and native code.

$ uname -a
Linux martin 2.6.23-gentoo-r3 #2 SMP Tue Jan 15 23:08:34 CET 2008 x86_64 AMD Turion(tm) 64 X2 Mobile Technology TL-50 AuthenticAMD GNU/Linux

$ cat toto.mll
(*
Here's the full program.
Compile with:

ocamllex toto.mll
ocamlc -g -o toto.run -rectypes toto.ml
ocamlopt -o toto -rectypes toto.ml

Run it without arguments.
*)

let x = [^' ']* as x
let y = 'A'? ' '

rule line = parse
| "====" x y { line lexbuf }
| "===" x y { line lexbuf }
| "==" x y { line lexbuf }
| "=" x y { line lexbuf }
| "{{{" x y { verbatim [x] lexbuf }
| x y { line lexbuf }

and verbatim accu = parse
"}}}" y { ignore (List.rev accu) }
| x y { verbatim (x :: accu) lexbuf }

{
let _ = line (Lexing.from_string "{{{ }}} ")
}

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 3, 2008

Comment author: @mjambon

The -rectypes flag is superfluous.

Here's a slightly shorter version of the program:

let x = [^' ']* as x
let y = 'A'? ' '

rule line = parse
| "====" x y { () }
| "===" x y { () }
| "==" x y { () }
| "=" x y { () }
| "{{{" x y { verbatim [x] lexbuf }
| x y { line lexbuf }

and verbatim accu = parse
"}}}" y { ignore (List.rev accu) }
| x y { verbatim (x :: accu) lexbuf }

{
let _ = line (Lexing.from_string "{{{ }}} ")
}

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 7, 2008

Comment author: @damiendoligez

Doesn't crash with 3.10.2 on x86.
Doesn't crash with 3.10.1 on x86 either.

Seems to be a 64-bit related problem.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 7, 2008

Comment author: @maranget

This is indeed a bug of ocamllex, which I managed to reproduce with all recent ocaml versions (including 3.10.2 on AMD64).

--
Luc

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 7, 2008

Comment author: @maranget

Bug corrected in HEAD.

--Luc

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 7, 2008

Comment author: @maranget

Bug partly due to the imperative nature of ocamllex code.
Corrected in HEAD of cvs, which I assume to be 3.11+dev

--Luc

@vicuna vicuna closed this Apr 29, 2010

@vicuna vicuna added the bug label Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.