-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Labels
forwarded-to-js-devsThis report has been forwarded to Jane Street's internal review system.This report has been forwarded to Jane Street's internal review system.
Description
Hello JaneStreet folks, I think I came accross a memory leak with Core and Ocaml 5.0, running this:
open Core
let main () =
at_exit Gc.full_major;
let str = Bigstring.create 11 in
Bigstring.set str 0 'H';
Bigstring.set str 1 'e';
Bigstring.set str 2 'l';
Bigstring.set str 3 'l';
Bigstring.set str 4 'o';
Bigstring.set str 5 ' ';
Bigstring.set str 6 'w';
Bigstring.set str 7 'o';
Bigstring.set str 8 'r';
Bigstring.set str 9 'l';
Bigstring.set str 10 'd';
Printf.printf "%s\n" (Bigstring.to_string str)
let () = main ()
let ( ) = Gc.full_major ()
with ocaml 5.0 and core 0.15.1 shows a memory leak and I suspect it is a core issue.
I first opened this issue in ocaml repo (ocaml/ocaml#12161) where @Octachron helped me and proved that it could be Core, not ocaml to blame.
Repro steps:
sudo dnf install libasan libubsan
ocamlfind ocamlopt -thread -package core -linkpkg -ccopt -fsanitize=address -ccopt -O0 hello.ml -o a.out
ASAN_OPTIONS=detect_leaks=1 ./a.out
output:
Hello world
=================================================================
==3272424==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 96 byte(s) in 1 object(s) allocated from:
#0 0x3f1acf in malloc (/testOcaml5/__hello__/hello.opt+0x3f1acf)
#1 0x804f93 in caml_thread_new_descriptor /.opam-switch/build/ocaml-variants.5.0.0+options/otherlibs/systhreads/st_pthreads.h:244:16
#2 0x805123 in caml_thread_domain_initialize_hook /.opam-switch/build/ocaml-variants.5.0.0+options/otherlibs/systhreads/st_stubs.c:427:23
#3 0x8057c6 in caml_thread_initialize /.opam-switch/build/ocaml-variants.5.0.0+options/otherlibs/systhreads/st_stubs.c:473:3
#4 0x832312 in caml_c_call (/testOcaml5/__hello__/hello.opt+0x832312)
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x3f1acf in malloc (/testOcaml5/__hello__/hello.opt+0x3f1acf)
#1 0x82dfc9 in caml_ml_mutex_new /.opam-switch/build/ocaml-variants.5.0.0+options/runtime/sync_posix.h:44:7
#2 0x832312 in caml_c_call (/testOcaml5/__hello__/hello.opt+0x832312)
Direct leak of 11 byte(s) in 4 object(s) allocated from:
#0 0x3f1acf in malloc (/testOcaml5/__hello__/hello.opt+0x3f1acf)
#1 0x80c79c in caml_ba_alloc /.opam-switch/build/ocaml-variants.5.0.0+options/runtime/bigarray.c:111:12
#2 0x80c99c in caml_ba_create /.opam-switch/build/ocaml-variants.5.0.0+options/runtime/bigarray.c:521:10
#3 0x832312 in caml_c_call (/testOcaml5/__hello__/hello.opt+0x832312)
SUMMARY: AddressSanitizer: 147 byte(s) leaked in 6 allocation(s).
Metadata
Metadata
Assignees
Labels
forwarded-to-js-devsThis report has been forwarded to Jane Street's internal review system.This report has been forwarded to Jane Street's internal review system.