Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006364OCamlback end (clambda to assembly)public2014-04-08 15:252014-06-05 16:31
Assigned To 
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: [^]

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
$ ocamlopt -c -o power.cmx
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 [^] (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
kerneis (reporter)
2014-04-08 15:39

Attached compressed test file.
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 (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
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:
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
2017-02-23 16:35 doligez Category OCaml backend (code generation) => Back end (clambda to assembly)
2017-02-23 16:44 doligez Category Back end (clambda to assembly) => back end (clambda to assembly)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker