My (common) suspect is Zarith. It uses a different backend when compiled to bytecode, so I would start my investigation from this point :) Hope it helps, Ivan On Tue, May 28, 2019 at 8:27 AM Jon French wrote: > Hi all, > > I'm wondering if anyone on this list might have encountered this issue > before, since it's got me pretty stumped. > > We have an OCaml project ( https://github.com/rems-project/sail ) which > tries to allocate huge amounts of memory, but only when compiled to > bytecode. The native version works perfectly fine. > > strace for an example run ends in: > > openat(AT_FDCWD, "/home/ojno/work/sail2/lib/vector_dec.sail", > O_RDONLY|O_CLOEXEC) = 3 > lseek(3, 0, SEEK_CUR) = 0 > read(3, "$ifndef _VECTOR_DEC\n$define _VEC"..., 65536) = 7031 > mmap(NULL, 1965819695104, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, 0) = -1 ENOMEM (Cannot allocate memory) > brk(0x5729f32c4000) = 0x55603f2f4000 > mmap(NULL, 1965819826176, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, > -1, 0) = -1 ENOMEM (Cannot allocate memory) > write(2, "Fatal error: out of memory.\n", 28Fatal error: out of memory. > ) = 28 > exit_group(2) = ? > +++ exited with 2 +++ > > > which naturally fails since I don't have 2 TB of memory available. > > The exact amount of the allocation varies from input to input and even run > to run, but is always that approximate size. There's no characteristic > pattern of heap or stack running out of control if I turn on memory > debugging info in $OCAMLRUNPARAM, just that one huge allocation. When run > in ocamldebug, it also doesn't appear to be failing at a location which is > sensible to be allocating such amounts of memory -- and the location also > varies with the input. And on tiny inputs it doesn't seem to try and make > the allocation at all. > > Are we actually seeing a compiler/runtime bug here? Is there something I'm > missing? > > Thanks, > > Jon French > Computer Laboratory > University of Cambridge >