Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004718OCamlOCamldocpublic2009-02-16 09:152012-09-25 20:10
Reporterwarren 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionunable to reproduce 
PlatformOSOS Version
Product Version3.10.2 
Target VersionFixed in Version 
Summary0004718: unterminated quote causes crash
DescriptionIf 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
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0005560)
guesdon (manager)
2010-06-16 13:40

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.
(0005572)
aostruszka (reporter)
2010-06-29 15:25
edited on: 2010-06-29 15:33

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

(0005778)
Camarade_Tux (reporter)
2011-01-17 14:37

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.
(0006929)
glondu (reporter)
2012-02-16 09:20

> 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.
(0007125)
xleroy (administrator)
2012-03-21 16:35

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

- Issue History
Date Modified Username Field Change
2009-02-16 09:15 warren New Issue
2009-02-16 09:15 warren Status new => assigned
2009-02-16 09:15 warren Assigned To => ertai
2010-06-16 12:22 ertai Assigned To ertai => guesdon
2010-06-16 13:40 guesdon Note Added: 0005560
2010-06-16 13:40 guesdon Assigned To guesdon =>
2010-06-16 13:41 guesdon Status assigned => feedback
2010-06-29 15:25 aostruszka Note Added: 0005572
2010-06-29 15:33 aostruszka Note Edited: 0005572
2011-01-17 14:37 Camarade_Tux Note Added: 0005778
2012-02-16 09:20 glondu Note Added: 0006929
2012-03-21 16:35 xleroy Note Added: 0007125
2012-03-21 16:35 xleroy Status feedback => resolved
2012-03-21 16:35 xleroy Resolution open => unable to reproduce
2012-09-25 20:10 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker