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

unterminated quote causes crash #4718

Closed
vicuna opened this issue Feb 16, 2009 · 5 comments
Closed

unterminated quote causes crash #4718

vicuna opened this issue Feb 16, 2009 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Feb 16, 2009

Original bug ID: 4718
Reporter: warren
Status: closed (set by @xavierleroy on 2012-09-25T18:10:24Z)
Resolution: unable to duplicate
Priority: normal
Severity: crash
Version: 3.10.2
Category: ocamldoc
Monitored by: @glondu

Bug description

If an ocamldoc-style comment contains an unterminated quote, a crash occurs when preprocessing the file, e.g.

(** hello " *)

Fatal error: exception Loc.Exc_located(_, _)
Raised at file "camlp4/Camlp4/Struct/Lexer.mll", line 186, characters 9-46
Called from file "camlp4/Camlp4/Struct/Lexer.mll", line 357, characters 12-54
Called from file "camlp4/Camlp4/Struct/Lexer.mll", line 155, characters 4-21
Called from file "camlp4/Camlp4/Struct/Lexer.mll", line 294, characters 26-63
Called from file "camlp4/Camlp4/Struct/Lexer.mll", line 454, characters 16-37
Called from file "stream.ml", line 78, characters 22-36
Called from file "stream.ml", line 111, characters 8-14
Called from file "build/optcomp/optcomp.ml", line 96, characters 42-48
Called from file "stream.ml", line 78, characters 22-36
Called from file "build/optcomp/pa_optcomp.ml", line 365, characters 47-53
Called from file "build/optcomp/pa_optcomp.ml", line 558, characters 26-38
Called from file "build/optcomp/pa_optcomp.ml", line 678, characters 48-57
Called from file "stream.ml", line 78, characters 22-36
Called from file "stream.ml", line 124, characters 10-19
Called from file "build/optcomp/optcomp.ml", line 111, characters 6-167
Re-raised at file "build/optcomp/optcomp.ml", line 96, characters 24-147
Called from file "build/optcomp/optcomp_o.ml", line 12, characters 21-23
Preprocessing error on file src/core/extlib/substring.mli

@vicuna
Copy link
Author

vicuna commented Jun 16, 2010

Comment author: @zoggy

Having an unterminated string in a comment is an ocaml error:

cat > t.ml

(* "coucou le commentaire avec une mauvaise chaine *)
let x = 1;;
^D

#ocaml t.ml
File "t.ml", line 1, characters 0-2:
Error: This comment contains an unterminated string literal

This is not an ocamldoc related problem. The error occurs when calling the ocaml parser.

@vicuna
Copy link
Author

vicuna commented Jun 29, 2010

Comment author: aostruszka

Applies to both ocamlc and camlp4 (3.11.2)

$ cat dupa.ml
(* Some " to be printed *)
let () = print_char '"'; print_newline ();;

$ ocamlc dupa.ml
File "dupa.ml", line 1, characters 0-2:
Error: Comment not terminated

$ ocamlc -pp camlp4o dupa.ml
File "dupa.ml", line 1, characters 0-71 (end at line 3, character 0):
Comment not terminated
File "dupa.ml", line 1, characters 0-1:
Error: Preprocessor error

@vicuna
Copy link
Author

vicuna commented Jan 17, 2011

Comment author: Camarade_Tux

This also lead to the disappearance of code sometimes. I just had a whole chunk of a file that disappeared because of that behaviour.

    Objective Caml version 3.12.0

(* a " a *)

let x = 42 in
(* b " b *)
x;;
Error: Unbound value x

Maybe that having lone " between (* and *) should be forbidden? Or at least, it could emit a warning. I hopefully had camlp4 parsing and also had to see the temp file instead of the source directly, but without that, I would probably have spent some time on this issue.

@vicuna
Copy link
Author

vicuna commented Feb 16, 2012

Comment author: @glondu

Having an unterminated string in a comment is an ocaml error [...]

Is this documented somewhere? I would expect it in section 6.1 ("Lexical conventions", paragraph "Comments"), but couldn't find mention of this even by grepping through the whole manual.

@vicuna
Copy link
Author

vicuna commented Mar 21, 2012

Comment author: @xavierleroy

I can't reproduce the crash with OCaml 4.00 dev. Closing this PR.

$ cat foo.ml
cat dupa.ml
(* Some " to be printed *)
let () = print_char '"'; print_newline ();;
$ ocamldoc foo.ml
File "foo.ml", line 2, characters 0-2:
Error: Comment not terminated
1 error(s) encountered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant