Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006364OCamlOCaml backend (code generation)public2014-04-08 15:252014-06-05 16:31
Reporterkerneis 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionsuspended 
PlatformOSOS Version
Product Version4.01.0 
Target VersionFixed in Version 
Summary0006364: ocamlopt crashes with "Fatal error: exception Stack_overflow"
DescriptionThe following file (too large to be hosted on Mantis) is a 5.4MB .ml file generated automatically:

https://gist.githubusercontent.com/kerneis/9af54c536d5e07b9e2c8/raw/0c5ee22ea5d37143d56116977eccdd2d133f64a7/gistfile1.ml [^]

It consists of a few type definitions for an AST, and then a single, huge term (let defs starting on line 448). It is probably pathological, but here is what happens when I try and compile it anyway:

$ ocamlc.opt -c -o power.cmo gistfile1.ml
$ ocamlopt -c -o power.cmx gistfile1.ml
Fatal error: exception Stack_overflow

I get the same results with ocamlc.opt and ocamlopt.opt.

I'm not sure it's worth spending too many efforts fixing, but I figured it might help uncover some bug in ocamlopt.
TagsNo tags attached.
Attached Filesgz file icon gistfile1.ml.gz [^] (250,742 bytes) 2014-04-08 15:36

- Relationships
related to 0005626resolved Stack overflow in ocamlopt.opt: Comballoc.combine 
related to 0005925resolvedgasche Stack overflow in compiler 

-  Notes
(0011246)
kerneis (reporter)
2014-04-08 15:39

Attached compressed test file.
(0011247)
yallop (developer)
2014-04-08 16:58

The culprit seems to be non-tail recursion in the backend, in particular Compilenv.structured_constants, which uses List.map (and so could be easily fixed), and Comballoc.combine, which requires a bit more work.

In the meantime, you may be able to work around the issue with something like 'ulimit'. The following works for me:

  $ ulimit -s 65536
  $ ocamlopt.opt -c gistfile1.ml
(0011680)
xleroy (administrator)
2014-06-05 16:30

I am marking this PR as "suspended" for the reasons given in 0005925, namely: making the native-code generator tail-recursive is a very invasive change, and supporting huge generated source files is a low priority.


- Issue History
Date Modified Username Field Change
2014-04-08 15:25 kerneis New Issue
2014-04-08 15:36 kerneis File Added: gistfile1.ml.gz
2014-04-08 15:39 kerneis Note Added: 0011246
2014-04-08 16:58 yallop Note Added: 0011247
2014-05-30 11:05 shinwell Status new => acknowledged
2014-05-30 11:51 gasche Relationship added related to 0005626
2014-06-05 16:30 xleroy Note Added: 0011680
2014-06-05 16:30 xleroy Status acknowledged => resolved
2014-06-05 16:30 xleroy Resolution open => suspended
2014-06-05 16:31 xleroy Relationship added related to 0005925


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker