Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004328OCamlCamlp4public2007-06-23 03:422010-04-29 14:26
Reportercstork 
Assigned Toertai 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.10.0 
Target VersionFixed in Version3.10+dev 
Summary0004328: Handling of nil nodes is suboptimal
DescriptionIf I try to pretty print

  <:str_item< type $t$; ... >>

where t could potentially be a nil node, ie, <:ctyp<>>, then camlp4r produces a stack overflow.

Two suggestions:

1) CleanAst.ml could easily turn such empty str_item nodes into <:str_item<>>. Attached is a simple patch that achieves this for this case. If there's interest I'd extend this patch to cover more useful cases. This has the potential to make writing camlp4 extensions more pleasant.

2) camlp4 shouldn't simply crash on nil nodes, but produce a meaningful error message. In case that such a nil node is not pretty printed but dump'ed the error message is

  Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml",
  line 792, char 11

which is a bit more helpful.
Additional InformationTo reproduce:

$ echo << DONE
open Camlp4.PreCast.Syntax;
EXTEND Gram
   GLOBAL: str_item;
   str_item: [[ "type_Nil" -> <:str_item< type $ <:ctyp<>> $ >> ]];
END;
DONE > pa_type_Nil.ml
$ ocamlc -c -pp camlp4rf -I +camlp4 pa_type_Nil.ml
$ echo "type_Nil;" > type_Nil.ml
$ camlp4r pa_type_Nil.cmo type_Nil.ml
type (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...
Camlp4: Uncaught exception: Stack_overflow
TagsNo tags attached.
Attached Filespatch file icon CleanAst.patch [^] (981 bytes) 2007-06-23 03:42 [Show Content]

- Relationships

-  Notes
(0004336)
ertai (developer)
2007-11-21 17:29

Thanks for your report. That's fixed in CVS.

- Issue History
Date Modified Username Field Change
2007-06-23 03:42 cstork New Issue
2007-06-23 03:42 cstork File Added: CleanAst.patch
2007-11-10 15:10 xleroy Status new => assigned
2007-11-10 15:10 xleroy Assigned To => ertai
2007-11-21 17:29 ertai Note Added: 0004336
2007-11-21 17:29 ertai Status assigned => resolved
2007-11-21 17:29 ertai Resolution open => fixed
2007-11-21 17:29 ertai Fixed in Version => 3.10+dev
2010-04-29 14:26 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker