caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@college-de-france.fr>
To: Jon French <jf451@cam.ac.uk>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Only bytecode version of executable allocating huge amounts
Date: Tue, 28 May 2019 19:16:31 +0200	[thread overview]
Message-ID: <CAH=h3gF_JBi29Mfp=EMKaQr2aG6x-dz-zoXK2fQ+fJKyFwd8RA@mail.gmail.com> (raw)
In-Reply-To: <8d058e9d-5293-46f1-9941-7c33fd232e04@www.fastmail.com>

[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]

On Tue, May 28, 2019 at 2:27 PM Jon French <jf451@cam.ac.uk> 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.
>

This is unusual indeed.

Do you have a repro case that you could share publicly?  If so, please
submit an issue at https://github.com/ocaml/ocaml/issues and attach the
repro.

The first thing I would do is to increase the verbosity of the GC: set the
OCAMLRUNPARAM environment variable to the value "v=255".  The resulting GC
traces can give an idea of what's going on.

Kind regards,

- Xavier Leroy




>
> 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
>

[-- Attachment #2: Type: text/html, Size: 3536 bytes --]

  parent reply	other threads:[~2019-05-28 17:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 11:32 Jon French
2019-05-28 16:49 ` rixed
2019-05-28 17:16 ` Xavier Leroy [this message]
2019-05-28 17:23 ` Ivan Gotovchits
2019-05-28 17:58   ` Fabrice Le Fessant
2019-05-29 15:22     ` Jon French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH=h3gF_JBi29Mfp=EMKaQr2aG6x-dz-zoXK2fQ+fJKyFwd8RA@mail.gmail.com' \
    --to=xavier.leroy@college-de-france.fr \
    --cc=caml-list@inria.fr \
    --cc=jf451@cam.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).