Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlc.opt tries to allocate 34 GB of RAM ... and fails
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: ocamlc.opt tries to allocate 34 GB of RAM ... and fails

We had a bug reported ages ago where ocamlc.opt would try to allocate
a ridiculous amount of RAM (34289692672 bytes, or about 34 GB) and
fail.  Another very similar bug report[1] has just come along, with a
nice small reproducer:

------------------------------------------------------------ log.ml
open Camlp4.PreCast;
open Syntax;


value insert_mname_mline _loc f = <:expr<Log.$lid:f$ $str:Loc.file_name  _loc$
$`int:Loc.start_line _loc$>>;

EXTEND Gram
  GLOBAL: expr;

    expr:
      [
        [ "Log"; "."; f = [ `LIDENT ("e"|"d"|"w" as f) -> f] ->
insert_mname_mline _loc f ]
      ];
  END;
----------------------------------------------------------------------

Running:

  ocamlc.opt -c -I +camlp4 -pp camlp4rf log.ml

_sometimes_ fails with an out of memory error, eg:

  for i in `seq 1 100`; do ocamlc.opt -c -I +camlp4 -pp camlp4rf log.ml; done

For me it fails about 1 time in 10.

There's some evidence this may be a Fedora-specific problem, maybe
some problem in the kernel or glibc or how we build OCaml, however I
have no real idea so I'm wondering if anyone can try reproducing it.

Rich.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=445545

-- 
Richard Jones
Red Hat