Skip to content

OCaml 4.13 memory leak in caml_setup_stack_overflow_detection #10698

@rwmjones

Description

@rwmjones

Run any ocamlopt-compiled program under valgrind --leak-check=full and you will see:

==2560078== 8,192 bytes in 1 blocks are definitely lost in loss record 25 of 33
==2560078==    at 0x484086F: malloc (vg_replace_malloc.c:380)
==2560078==    by 0x13C969: caml_setup_stack_overflow_detection (in /var/tmp/test)
==2560078==    by 0x13C9E3: caml_init_signals (in /var/tmp/test)
==2560078==    by 0x13B684: caml_startup_common (in /var/tmp/test)
==2560078==    by 0x13B76E: caml_main (in /var/tmp/test)
==2560078==    by 0x11C6D1: main (in /var/tmp/test)

This leak seems to be new in OCaml 4.13.1.

In nbdkit we maintain a set of valgrind suppressions for OCaml, and the only ones we expect are functions matching caml_stat_alloc*: https://gitlab.com/nbdkit/nbdkit/-/blob/master/valgrind/ocaml.suppressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions