Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"malloc(): unsorted double linked list corrupted" errors #453

Closed
Khady opened this issue Dec 8, 2020 · 2 comments
Closed

"malloc(): unsorted double linked list corrupted" errors #453

Khady opened this issue Dec 8, 2020 · 2 comments
Assignees

Comments

@Khady
Copy link
Contributor

Khady commented Dec 8, 2020

I've just installed a 4.10 multicore switch successfully. But after that, I struggled a lot to compile any ocaml code in it. Almost every time I try to build something, I get a malloc(): unsorted double linked list corrupted errors.

All of this happens on a server with 40 cores, 256gb of ram, debian 10.3.

Switch installation command:

opam switch create 4.10.0+multicore --packages=ocaml-variants.4.10.0+multicore --repositories=multicore=git+https://github.com/ocaml-multicore/multicore-opam.git,default

My goal was to compile https://github.com/shubhamkumar13/effects-examples/tree/migrate-to-dune. So once I got my switch I tried to install lwt. And got those errors. I had to run the opam install lwt --yes until it would actually pass. Basically every package that was being installed in the switch failed to build at least once.

#=== ERROR while compiling lwt.5.3.0 ==========================================#
# context     2.0.6 | linux/x86_64 | ocaml-variants.4.10.0+multicore | git+https://github.com/ocaml-multicore/multicore-opam.git
# path        ~/.opam/4.10.0+multicore/.opam-switch/build/lwt.5.3.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p lwt -j 39
# exit-code   1
# env-file    ~/.opam/log/lwt-7224-6d07ae.env
# output-file ~/.opam/log/lwt-7224-6d07ae.out
### output ###
# malloc(): unsorted double linked list corrupted
# [...]
# (cd _build/default/src/unix && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I. -g -I /home/louis/.opam/4.10.0+multicore/lib/ocaml -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.o[...]
# malloc(): unsorted double linked list corrupted
#          gcc src/unix/unix_readable.o (got signal ABRT)
# (cd _build/default/src/unix && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I. -g -I /home/louis/.opam/4.10.0+multicore/lib/ocaml -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.o[...]
# malloc(): unsorted double linked list corrupted
#          gcc src/unix/unix_tcdrain_job.o (got signal ABRT)
# (cd _build/default/src/unix && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I. -g -I /home/louis/.opam/4.10.0+multicore/lib/ocaml -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.o[...]
# malloc(): unsorted double linked list corrupted
#          gcc src/unix/unix_wait4.o (got signal ABRT)
# (cd _build/default/src/unix && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT -I. -g -I /home/louis/.opam/4.10.0+multicore/lib/ocaml -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.o[...]
# malloc(): unsorted double linked list corrupted
#=== ERROR while compiling ocplib-endian.1.1 ==================================#
# context     2.0.6 | linux/x86_64 | ocaml-variants.4.10.0+multicore | https://opam.ocaml.org#09d02dd3
# path        ~/.opam/4.10.0+multicore/.opam-switch/build/ocplib-endian.1.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ocplib-endian -j 39 @install
# exit-code   1
# env-file    ~/.opam/log/ocplib-endian-35539-a71bb4.env
# output-file ~/.opam/log/ocplib-endian-35539-a71bb4.out
### output ###
#         cppo src/endianString.mli (got signal ABRT)
# (cd _build/default/src && /home/louis/.opam/4.10.0+multicore/bin/cppo endianString.cppo.mli -o endianString.mli)
# malloc(): unsorted double linked list corrupted
#=== ERROR while compiling cppo.1.6.6 =========================================#
# context     2.0.6 | linux/x86_64 | ocaml-variants.4.10.0+multicore | https://opam.ocaml.org#09d02dd3
# path        ~/.opam/4.10.0+multicore/.opam-switch/build/cppo.1.6.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p cppo -j 39
# exit-code   1
# env-file    ~/.opam/log/cppo-34441-c743ac.env
# output-file ~/.opam/log/cppo-34441-c743ac.out
### output ###
#     ocamldep src/.cppo_main.eobjs/cppo_parser.ml.d (got signal ABRT)
# (cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl src/cppo_parser.ml) > _build/default/src/.cppo_main.eobjs/cppo_parser.ml.d
# malloc(): unsorted double linked list corrupted
#     ocamldep src/.cppo_main.eobjs/cppo_eval.mli.d (got signal ABRT)
# (cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -intf src/cppo_eval.mli) > _build/default/src/.cppo_main.eobjs/cppo_eval.mli.d
# malloc(): unsorted double linked list corrupted
#=== ERROR while compiling dune.2.7.1 =========================================#
# context     2.0.6 | linux/x86_64 | ocaml-variants.4.10.0+multicore | https://opam.ocaml.org#09d02dd3
# path        ~/.opam/4.10.0+multicore/.opam-switch/build/dune.2.7.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./dune.exe build -p dune --profile dune-bootstrap -j 39
# exit-code   1
# env-file    ~/.opam/log/dune-27354-c61e7b.env
# output-file ~/.opam/log/dune-27354-c61e7b.out
### output ###
#         dune doc/dune-install.1 (got signal ABRT)
# (cd _build/default/doc && ../../install/default/bin/dune install --help=groff) > _build/default/doc/dune-install.1
# malloc(): unsorted double linked list corrupted
#         dune doc/dune-promote.1 (got signal ABRT)
# (cd _build/default/doc && ../../install/default/bin/dune promote --help=groff) > _build/default/doc/dune-promote.1
# malloc(): unsorted double linked list corrupted
#         dune doc/dune-runtest.1 (got signal ABRT)
# (cd _build/default/doc && ../../install/default/bin/dune runtest --help=groff) > _build/default/doc/dune-runtest.1
# malloc(): unsorted double linked list corrupted

I never managed to install the lwt package until I did opam install lwt -j 1.

After that, I tried to compile the effects examples. Again, I have the malloc errors. On different files.

$ DUNE_CACHE=disabled dune clean
$ DUNE_CACHE=disabled dune build
    ocamldep .memo.eobjs/memo.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl memo.ml) > _build/default/.memo.eobjs/memo.ml.d
malloc(): unsorted double linked list corrupted
    ocamldep .nim.eobjs/nim.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl nim.ml) > _build/default/.nim.eobjs/nim.ml.d
malloc(): unsorted double linked list corrupted
    ocamldep .queens.eobjs/queens.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl queens.ml) > _build/default/.queens.eobjs/queens.ml.d
malloc(): unsorted double linked list corrupted
    ocamldep mvar/.chameneos.eobjs/chameneos_monad.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl mvar/chameneos_monad.ml) > _build/default/mvar/.chameneos.eobjs/chameneos_monad.ml.d
malloc(): unsorted double linked list corrupted
    ocamlopt pipes.exe (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlopt.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o pipes.exe .pipes.eobjs/native/dune__exe__Pipes.cmx)
malloc(): unsorted double linked list corrupted
Done: 185/207 (jobs: 1)
$ DUNE_CACHE=disabled dune clean
$ DUNE_CACHE=disabled dune build
    ocamldep .pipes.eobjs/pipes.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl pipes.ml) > _build/default/.pipes.eobjs/pipes.ml.d
malloc(): unsorted double linked list corrupted
    ocamldep .queens.eobjs/queens.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl queens.ml) > _build/default/.queens.eobjs/queens.ml.d
malloc(): unsorted double linked list corrupted
      ocamlc .nim.eobjs/byte/dune__exe__Nim.{cmi,cmo,cmt} (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I .nim.eobjs/byte -no-alias-deps -opaque -o .nim.eobjs/byte/dune__exe__Nim.cmo -c -impl nim.ml)
malloc(): unsorted double linked list corrupted
    ocamlopt dyn_wind.exe (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlopt.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o dyn_wind.exe .dyn_wind.eobjs/native/dune__exe__Dyn_wind.cmx)
malloc(): unsorted double linked list corrupted
    ocamlopt mvar/.chameneos.eobjs/native/dune__exe__MVar.{cmx,o} (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlopt.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -I mvar/.chameneos.eobjs/byte -I mvar/.chameneos.eobjs/native -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/lwt -I /home/louis/.opam/4.10.0+multicore/lib/lwt/unix -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.opam/4.10.0+multicore/lib/ocplib-endian -I /home/louis/.opam/4.10.0+multicore/lib/ocplib-endian/bigstring -I /home/louis/.opam/4.10.0+multicore/lib/result -I /home/louis/.opam/4.10.0+multicore/lib/seq -intf-suffix .ml -no-alias-deps -opaque -open Dune__exe -o mvar/.chameneos.eobjs/native/dune__exe__MVar.cmx -c -impl mvar/MVar.ml)
malloc(): unsorted double linked list corrupted
      ocamlc mvar/.chameneos.eobjs/byte/dune__exe__MVar_test.{cmi,cmo,cmt} (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I mvar/.chameneos.eobjs/byte -I /home/louis/.opam/4.10.0+multicore/lib/bytes -I /home/louis/.opam/4.10.0+multicore/lib/domainslib -I /home/louis/.opam/4.10.0+multicore/lib/lwt -I /home/louis/.opam/4.10.0+multicore/lib/lwt/unix -I /home/louis/.opam/4.10.0+multicore/lib/mmap -I /home/louis/.opam/4.10.0+multicore/lib/ocaml/threads -I /home/louis/.opam/4.10.0+multicore/lib/ocplib-endian -I /home/louis/.opam/4.10.0+multicore/lib/ocplib-endian/bigstring -I /home/louis/.opam/4.10.0+multicore/lib/result -I /home/louis/.opam/4.10.0+multicore/lib/seq -no-alias-deps -opaque -open Dune__exe -o mvar/.chameneos.eobjs/byte/dune__exe__MVar_test.cmo -c -impl mvar/MVar_test.ml)
malloc(): unsorted double linked list corrupted
Done: 213/232 (jobs: 1)

Again, by reducing the number of jobs I greattly increased to probably of the compilation working

$ DUNE_CACHE=disabled dune clean
$ DUNE_CACHE=disabled dune build -j 2
Done: 233/236 (jobs: 1)
$ DUNE_CACHE=disabled dune clean
$ DUNE_CACHE=disabled dune build -j 2
    ocamldep mvar/.chameneos.eobjs/sched.ml.d (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamldep.opt -modules -impl mvar/sched.ml) > _build/default/mvar/.chameneos.eobjs/sched.ml.d
malloc(): unsorted double linked list corrupted
      ocamlc .memo.eobjs/byte/dune__exe__Memo.{cmi,cmo,cmt} (got signal ABRT)
(cd _build/default && /home/louis/.opam/4.10.0+multicore/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I .memo.eobjs/byte -no-alias-deps -opaque -o .memo.eobjs/byte/dune__exe__Memo.cmo -c -impl memo.ml)
malloc(): unsorted double linked list corrupted
Done: 200/215 (jobs: 1)
$ DUNE_CACHE=disabled dune clean
$ DUNE_CACHE=disabled dune build -j 1
Done: 233/236 (jobs: 1)
@Khady
Copy link
Contributor Author

Khady commented Dec 8, 2020

The output of opam sw export --full

opam-version: "2.0"
compiler: [
  "base-bigarray.base"
  "base-threads.base"
  "base-unix.base"
  "ocaml.4.10.0"
  "ocaml-variants.4.10.0+multicore"
]
roots: [
  "dune.2.7.1"
  "lwt.5.3.0"
  "ocaml-variants.4.10.0+multicore"
  "ocamlbuild.0.14.0"
  "ocamlfind.1.8.1"
]
installed: [
  "base-bigarray.base"
  "base-bytes.base"
  "base-threads.base"
  "base-unix.base"
  "conf-m4.1"
  "cppo.1.6.6"
  "csexp.1.3.2"
  "domainslib.0.2.2"
  "dune.2.7.1"
  "dune-configurator.2.7.1"
  "lwt.5.3.0"
  "mmap.1.1.0"
  "ocaml.4.10.0"
  "ocaml-variants.4.10.0+multicore"
  "ocamlbuild.0.14.0"
  "ocamlfind.1.8.1"
  "ocplib-endian.1.1"
  "result.1.5"
  "seq.base"
]
package "base-bigarray" {
  opam-version: "2.0"
  version: "base"
  synopsis: ""
  description: "Bigarray library distributed with the OCaml compiler"
  maintainer: "https://github.com/ocaml/opam-repository/issues"
}
package "base-bytes" {
  opam-version: "2.0"
  version: "base"
  synopsis: "Bytes library distributed with the OCaml compiler"
  maintainer: " "
  authors: " "
  homepage: " "
  depends: [
    "ocaml" {>= "4.02.0"}
    "ocamlfind" {>= "1.5.3"}
  ]
}
package "base-threads" {
  opam-version: "2.0"
  version: "base"
  synopsis: ""
  description: "Threads library distributed with the OCaml compiler"
  maintainer: "https://github.com/ocaml/opam-repository/issues"
}
package "base-unix" {
  opam-version: "2.0"
  version: "base"
  synopsis: ""
  description: "Unix library distributed with the OCaml compiler"
  maintainer: "https://github.com/ocaml/opam-repository/issues"
}
package "conf-m4" {
  opam-version: "2.0"
  version: "1"
  synopsis: "Virtual package relying on m4"
  description:
    "This package can only install if the m4 binary is installed on the system."
  maintainer: "tim@gfxmonk.net"
  authors: "GNU Project"
  license: "GPL-3.0-only"
  homepage: "http://www.gnu.org/software/m4/m4.html"
  bug-reports: "https://github.com/ocaml/opam-repository/issues"
  flags: conf
  build: ["sh" "-exc" "echo | m4"]
  depexts: [
    ["m4"] {os-family = "debian"}
    ["m4"] {os-distribution = "fedora"}
    ["m4"] {os-distribution = "rhel"}
    ["m4"] {os-distribution = "centos"}
    ["m4"] {os-distribution = "alpine"}
    ["m4"] {os-distribution = "nixos"}
    ["m4"] {os-family = "suse"}
    ["m4"] {os-distribution = "ol"}
    ["m4"] {os-distribution = "arch"}
  ]
}
package "cppo" {
  opam-version: "2.0"
  version: "1.6.6"
  synopsis: "Code preprocessor like cpp for OCaml"
  description: """
Cppo is an equivalent of the C preprocessor for OCaml programs.
It allows the definition of simple macros and file inclusion.

Cppo is:

* more OCaml-friendly than cpp
* easy to learn without consulting a manual
* reasonably fast
* simple to install and to maintain"""
  maintainer: "martin@mjambon.com"
  authors: "Martin Jambon"
  license: "BSD-3-Clause"
  homepage: "http://mjambon.com/cppo.html"
  doc: "https://ocaml-community.github.io/cppo/"
  bug-reports: "https://github.com/ocaml-community/cppo/issues"
  depends: [
    "ocaml" {>= "4.03"}
    "dune" {>= "1.0"}
    "base-unix"
  ]
  build: [
    ["dune" "subst"] {pinned}
    ["dune" "build" "-p" name "-j" jobs]
    ["dune" "runtest" "-p" name "-j" jobs] {with-test}
  ]
  dev-repo: "git+https://github.com/ocaml-community/cppo.git"
  url {
    src:
      "https://github.com/ocaml-community/cppo/releases/download/v1.6.6/cppo-v1.6.6.tbz"
    checksum: [
      "sha256=e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0"
      "sha512=44ecf9d225d9e45490a2feac0bde04865ca398dba6c3579e3370fcd1ea255707b8883590852af8b2df87123801062b9f3acce2455c092deabf431f9c4fb8d8eb"
    ]
  }
}
package "csexp" {
  x-commit-hash: "19a2e7bc171a707059c73d78dd18e4e3ff03ac9b"
  opam-version: "2.0"
  version: "1.3.2"
  synopsis: "Parsing and printing of S-expressions in Canonical form"
  description: """
This library provides minimal support for Canonical S-expressions
[1]. Canonical S-expressions are a binary encoding of S-expressions
that is super simple and well suited for communication between
programs.

This library only provides a few helpers for simple applications. If
you need more advanced support, such as parsing from more fancy input
sources, you should consider copying the code of this library given
how simple parsing S-expressions in canonical form is.

To avoid a dependency on a particular S-expression library, the only
module of this library is parameterised by the type of S-expressions.

[1] https://en.wikipedia.org/wiki/Canonical_S-expressions"""
  maintainer: "Jeremie Dimino <jeremie@dimino.org>"
  authors: [
    "Quentin Hocquet <mefyl@gruntech.org>"
    "Jane Street Group, LLC <opensource@janestreet.com>"
    "Jeremie Dimino <jeremie@dimino.org>"
  ]
  license: "MIT"
  homepage: "https://github.com/ocaml-dune/csexp"
  doc: "https://ocaml-dune.github.io/csexp/"
  bug-reports: "https://github.com/ocaml-dune/csexp/issues"
  depends: [
    "dune" {>= "1.11"}
    "ocaml" {>= "4.02.3"}
    "result" {>= "1.5"}
  ]
  build: [
    ["dune" "subst"] {pinned}
    ["dune" "build" "-p" name "-j" jobs "@install" "@doc" {with-doc}]
  ]
  dev-repo: "git+https://github.com/ocaml-dune/csexp.git"
  url {
    src:
      "https://github.com/ocaml-dune/csexp/releases/download/1.3.2/csexp-1.3.2.tbz"
    checksum: [
      "sha256=f21f427b277f07e8bfd050e00c640a5893c1bf4b689147640fa383255dcf1c4a"
      "sha512=ff1bd6a7c6bb3a73ca9ab0506c9ec1f357657deaa9ecc7eb32955817d9b0f266d976af3e2b8fc34c621cb0caf1fde55f9a609dd184e2054f500bf09afeb83026"
    ]
  }
}
package "domainslib" {
  opam-version: "2.0"
  version: "0.2.2"
  synopsis: "Parallel Structures over Domains for Multicore OCaml"
  maintainer: "KC Sivaramakrishnan <kc@kcsrk.info>"
  authors: "KC Sivaramakrishnan <kc@kcsrk.info>"
  license: "ISC"
  homepage: "https://github.com/ocaml-multicore/domainslib"
  doc: "https://kayceesrk.github.io/domainslib/doc"
  bug-reports: "https://github.com/ocaml-multicore/domainslib/issues"
  depends: [
    "ocamlfind" {build}
    "dune" {build}
  ]
  build: ["dune" "build" "-p" name]
  dev-repo: "git+https://github.com/ocaml-multicore/domainslib.git"
  url {
    src: "https://github.com/ocaml-multicore/domainslib/archive/0.2.2.tar.gz"
    checksum: "md5=2f4b669c429db2650e64508f23ee7478"
  }
}
package "dune" {
  x-commit-hash: "5472766b2448308a7160dfd0fca1ec711e124a5c"
  opam-version: "2.0"
  version: "2.7.1"
  synopsis: "Fast, portable, and opinionated build system"
  description: """
dune is a build system that was designed to simplify the release of
Jane Street packages. It reads metadata from "dune" files following a
very simple s-expression syntax.

dune is fast, has very low-overhead, and supports parallel builds on
all platforms. It has no system dependencies; all you need to build
dune or packages using dune is OCaml. You don't need make or bash
as long as the packages themselves don't use bash explicitly.

dune supports multi-package development by simply dropping multiple
repositories into the same directory.

It also supports multi-context builds, such as building against
several opam roots/switches simultaneously. This helps maintaining
packages across several versions of OCaml and gives cross-compilation
for free."""
  maintainer: "Jane Street Group, LLC <opensource@janestreet.com>"
  authors: "Jane Street Group, LLC <opensource@janestreet.com>"
  license: "MIT"
  homepage: "https://github.com/ocaml/dune"
  doc: "https://dune.readthedocs.io/"
  bug-reports: "https://github.com/ocaml/dune/issues"
  depends: [
    ("ocaml" {>= "4.08"} | ("ocaml" {< "4.08~~"} & "ocamlfind-secondary"))
    "base-unix"
    "base-threads"
  ]
  conflicts: [
    "dune-configurator" {< "2.3.0"}
    "odoc" {< "1.3.0"}
    "dune-release" {< "1.3.0"}
    "js_of_ocaml-compiler" {< "3.6.0"}
    "jbuilder" {= "transition"}
  ]
  build: [
    ["ocaml" "configure.ml" "--libdir" lib] {opam-version < "2"}
    ["ocaml" "bootstrap.ml" "-j" jobs]
    ["./dune.exe" "build" "-p" name "--profile" "dune-bootstrap" "-j" jobs]
  ]
  dev-repo: "git+https://github.com/ocaml/dune.git"
  url {
    src:
      "https://github.com/ocaml/dune/releases/download/2.7.1/dune-2.7.1.tbz"
    checksum: [
      "sha256=c3528f2f8b3a2e3fe18e166fc823e6caeee8b7c78ade6b6fe4d2fa978070925d"
      "sha512=2b4b311824471dac8196181d7c7267f96b1b73f35341b72019f169cf6d42a19254e90bdfba2d3ecb138ad318e2e2431dd0ec6c38d9efe1da382ec95f5d9e959b"
    ]
  }
}
package "dune-configurator" {
  x-commit-hash: "5472766b2448308a7160dfd0fca1ec711e124a5c"
  opam-version: "2.0"
  version: "2.7.1"
  synopsis: "Helper library for gathering system configuration"
  description: """
dune-configurator is a small library that helps writing OCaml scripts that
test features available on the system, in order to generate config.h
files for instance.
Among other things, dune-configurator allows one to:
- test if a C program compiles
- query pkg-config
- import #define from OCaml header files
- generate config.h file"""
  maintainer: "Jane Street Group, LLC <opensource@janestreet.com>"
  authors: "Jane Street Group, LLC <opensource@janestreet.com>"
  license: "MIT"
  homepage: "https://github.com/ocaml/dune"
  doc: "https://dune.readthedocs.io/"
  bug-reports: "https://github.com/ocaml/dune/issues"
  depends: [
    "dune" {>= "2.7"}
    "ocaml" {>= "4.03.0"}
    "result"
    "csexp" {>= "1.3.0"}
    "odoc" {with-doc}
  ]
  build: [
    ["dune" "subst"] {dev}
    ["dune" "build" "-p" name "-j" jobs "@install" "@doc" {with-doc}]
  ]
  dev-repo: "git+https://github.com/ocaml/dune.git"
  url {
    src:
      "https://github.com/ocaml/dune/releases/download/2.7.1/dune-2.7.1.tbz"
    checksum: [
      "sha256=c3528f2f8b3a2e3fe18e166fc823e6caeee8b7c78ade6b6fe4d2fa978070925d"
      "sha512=2b4b311824471dac8196181d7c7267f96b1b73f35341b72019f169cf6d42a19254e90bdfba2d3ecb138ad318e2e2431dd0ec6c38d9efe1da382ec95f5d9e959b"
    ]
  }
}
package "lwt" {
  opam-version: "2.0"
  version: "5.3.0"
  synopsis: "Promises and event-driven I/O"
  description: """
A promise is a value that may become determined in the future.

Lwt provides typed, composable promises. Promises that are resolved by I/O are
resolved by Lwt in parallel.

Meanwhile, OCaml code, including code creating and waiting on promises, runs in
a single thread by default. This reduces the need for locks or other
synchronization primitives. Code can be run in parallel on an opt-in basis."""
  maintainer: "Sudha Parimala <sudharg247@gmail.com>"
  authors: ["Jérôme Vouillon" "Jérémie Dimino"]
  license: "MIT"
  homepage: "https://github.com/ocsigen/lwt"
  bug-reports: "https://github.com/Sudha247/lwt-multicore/issues"
  depends: [
    "cppo" {build & >= "1.1.0"}
    "dune" {>= "1.8.0"}
    "dune-configurator"
    "mmap" {>= "1.1.0"}
    "ocaml" {>= "4.02.0" & < "4.12"}
    ("ocaml" {>= "4.08.0"} | "ocaml-syntax-shims")
    "ocplib-endian"
    "result"
    "seq"
    "bisect_ppx" {dev & >= "2.0.0"}
    "ocamlfind" {dev & >= "1.7.3-1"}
    "domainslib"
  ]
  depopts: ["base-threads" "base-unix" "conf-libev"]
  conflicts: [
    "ocaml-variants" {= "4.02.1+BER"}
  ]
  build: [
    [
      "dune"
      "exec"
      "-p"
      name
      "src/unix/config/discover.exe"
      "--"
      "--save"
      "--use-libev"
      "%{conf-libev:installed}%"
    ]
    ["dune" "build" "-p" name "-j" jobs]
  ]
  dev-repo: "git+https://github.com/Sudha247/lwt-multicore.git"
  url {
    src:
      "https://github.com/Sudha247/lwt-multicore/archive/5.3.0+multicore.tar.gz"
    checksum: "md5=f4e0d7b89a7570e0d2f0f4486b9f729b"
  }
}
package "mmap" {
  opam-version: "2.0"
  version: "1.1.0"
  synopsis: "File mapping functionality"
  description:
    "This project provides a Mmap.map_file functions for mapping files in memory."
  maintainer: "jeremie@dimino.org"
  authors: ["Jérémie Dimino <jeremie@dimino.org>" "Anton Bachin"]
  license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
  homepage: "https://github.com/mirage/mmap"
  doc: "https://mirage.github.io/mmap/"
  bug-reports: "https://github.com/mirage/mmap/issues"
  depends: [
    "ocaml"
    "dune" {>= "1.6"}
  ]
  build: ["dune" "build" "-p" name "-j" jobs]
  dev-repo: "git+https://github.com/mirage/mmap.git"
  url {
    src:
      "https://github.com/mirage/mmap/releases/download/v1.1.0/mmap-v1.1.0.tbz"
    checksum: "md5=8c5d5fbc537296dc525867535fb878ba"
  }
}
package "ocaml-variants" {
  opam-version: "2.0"
  version: "4.10.0+multicore"
  synopsis: "OCaml 4.10.0, with support for multicore"
  maintainer: "platform@lists.ocaml.org"
  depends: [
    "ocaml" {= "4.10.0" & post}
    "base-unix" {post}
    "base-bigarray" {post}
    "base-threads" {post}
  ]
  conflict-class: "ocaml-core-compiler"
  flags: compiler
  setenv: CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs"
  build: [
    [
      "./configure"
      "--prefix"
      "%{prefix}%"
      "--enable-debug-runtime"
      "--disable-warn-error"
    ]
    ["%{make}%" "-j%{jobs}%" "world"]
    ["%{make}%" "-j%{jobs}%" "world.opt"]
  ]
  install: ["%{make}%" "install"]
  url {
    src:
      "https://github.com/ocamllabs/ocaml-multicore/archive/parallel_minor_gc.tar.gz"
  }
}
package "ocamlbuild" {
  opam-version: "2.0"
  version: "0.14.0"
  synopsis:
    "OCamlbuild is a build system with builtin rules to easily build most OCaml projects."
  maintainer: "Gabriel Scherer <gabriel.scherer@gmail.com>"
  authors: ["Nicolas Pouillard" "Berke Durak"]
  license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
  homepage: "https://github.com/ocaml/ocamlbuild/"
  doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc"
  bug-reports: "https://github.com/ocaml/ocamlbuild/issues"
  depends: [
    "ocaml" {>= "4.03"}
  ]
  conflicts: [
    "base-ocamlbuild"
    "ocamlfind" {< "1.6.2"}
  ]
  build: [
    [
      make
      "-f"
      "configure.make"
      "all"
      "OCAMLBUILD_PREFIX=%{prefix}%"
      "OCAMLBUILD_BINDIR=%{bin}%"
      "OCAMLBUILD_LIBDIR=%{lib}%"
      "OCAMLBUILD_MANDIR=%{man}%"
      "OCAML_NATIVE=%{ocaml:native}%"
      "OCAML_NATIVE_TOOLS=%{ocaml:native}%"
    ]
    [make "check-if-preinstalled" "all" "opam-install"]
  ]
  dev-repo: "git+https://github.com/ocaml/ocamlbuild.git"
  url {
    src: "https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz"
    checksum:
      "sha256=87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78"
  }
}
package "ocplib-endian" {
  opam-version: "2.0"
  version: "1.1"
  synopsis:
    "Optimised functions to read and write int16/32/64 from strings and bigarrays"
  description: """
The library implements three modules:
* [EndianString](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianString.mli) works directly on strings, and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts;
* [EndianBytes](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianBytes.mli) works directly on bytes, and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts;
* [EndianBigstring](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianBigstring.mli) works on bigstrings (Bigarrays of chars), and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts."""
  maintainer: "pierre.chambart@ocamlpro.com"
  authors: "Pierre Chambart"
  homepage: "https://github.com/OCamlPro/ocplib-endian"
  doc: "https://ocamlpro.github.io/ocplib-endian/ocplib-endian/"
  bug-reports: "https://github.com/OCamlPro/ocplib-endian/issues"
  depends: [
    "base-bytes"
    "ocaml" {>= "4.02.3"}
    "cppo" {>= "1.1.0" & build}
    "dune" {>= "1.0"}
  ]
  build: [
    "dune"
    "build"
    "-p"
    name
    "-j"
    jobs
    "@install"
    "@runtest" {with-test}
    "@doc" {with-doc}
  ]
  dev-repo: "git+https://github.com/OCamlPro/ocplib-endian.git"
  url {
    src: "https://github.com/OCamlPro/ocplib-endian/archive/1.1.tar.gz"
    checksum: [
      "md5=dedf4d69c1b87b3c6c7234f632399285"
      "sha512=39351c666d1394770696fa89ac62f7c137ad1697d99888bfba2cc8de2c61df05dd8b3aa327c117bf38f3e29e081026d2c575c5ad0022bde92b3d43aba577d3f9"
    ]
  }
}
package "result" {
  opam-version: "2.0"
  version: "1.5"
  synopsis: "Compatibility Result module"
  description: """
Projects that want to use the new result type defined in OCaml >= 4.03
while staying compatible with older version of OCaml should use the
Result module defined in this library."""
  maintainer: "opensource@janestreet.com"
  authors: "Jane Street Group, LLC <opensource@janestreet.com>"
  license: "BSD-3-Clause"
  homepage: "https://github.com/janestreet/result"
  bug-reports: "https://github.com/janestreet/result/issues"
  depends: [
    "ocaml"
    "dune" {>= "1.0"}
  ]
  build: ["dune" "build" "-p" name "-j" jobs]
  dev-repo: "git+https://github.com/janestreet/result.git"
  url {
    src:
      "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz"
    checksum: "md5=1b82dec78849680b49ae9a8a365b831b"
  }
}

@abbysmal abbysmal self-assigned this Dec 8, 2020
@abbysmal
Copy link
Collaborator

abbysmal commented Dec 9, 2020

Hello,
Thank you for your report.

I think this is connected to a recent change in systhreads in #439.
More specifically, the culprit seems to be that now, after fork, threads resources are properly freed by the runtime:
https://github.com/ocaml-multicore/ocaml-multicore/pull/439/files#diff-6bc1eb5d8edb8bd3593546c93ab7f58de42768b3941731da9f2b00d3652b3d87R261

It seems it trigger a kind of memory corruption and will eventually lead to the downfall of the forked process.

I isolated a smaller case that trigger reliably enough.

let alloc_string () = ignore(String.make 2048 '0')

let compute_thread () =
  Thread.create begin fun () ->
    alloc_string ()
  end ()

let fork () =
  match Unix.fork() with
  | 0 -> alloc_string ()
  | pid -> exit 0

let main () =
  ignore(compute_thread ());
  ignore(compute_thread ());
  ignore(compute_thread ());
  fork ()

let _ = main()

For the crash to happen, there is a need for allocations, and the more threads are spun up by the parent process, the more likely it crashes, although all of this is still a bit blurry for now.

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7c66859 in __GI_abort () at abort.c:79
#2  0x00007ffff7cd13ee in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7dfb285 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007ffff7cd947c in malloc_printerr (str=str@entry=0x7ffff7dfdad8 "malloc(): unsorted double linked list corrupted") at malloc.c:5347
#4  0x00007ffff7cdc46c in _int_malloc (av=av@entry=0x7ffff7e2cb80 <main_arena>, bytes=bytes@entry=2080) at malloc.c:3744
#5  0x00007ffff7cde419 in __GI___libc_malloc (bytes=2080) at malloc.c:3066
#6  0x0000555555623300 in large_allocate (sz=2064, local=0x5555556a68e0) at shared_heap.c:396
#7  caml_shared_try_alloc (local=0x5555556a68e0, wosize=wosize@entry=257, tag=tag@entry=252, pinned=pinned@entry=0) at shared_heap.c:396
#8  0x000055555560c932 in alloc_shr (noexc=0, tag=252, wosize=257) at memory.c:353
#9  caml_alloc_shr (wosize=257, tag=252) at memory.c:383
#10 0x000055555560d0ed in caml_alloc (wosize=<optimized out>, tag=<optimized out>) at alloc.c:50
#11 0x000055555560e5a6 in caml_alloc_string (len=2048) at alloc.c:193
#12 <signal handler called>
#13 0x00005555555cf31c in camlStdlib__bytes__make_94 () at bytes.ml:42
#14 0x00005555555b92ac in camlTestfork__fork_138 () at string.ml:41
#15 0x00005555555b948e in camlTestfork__entry () at testfork.ml:33
#16 0x00005555555b62d4 in caml_program ()
#17 <signal handler called>
#18 0x0000555555606bef in caml_startup_common (argv=0x7fffffffdd28, pooling=<optimized out>, pooling@entry=0) at startup_nat.c:141
#19 0x0000555555606c2c in caml_startup_exn (argv=<optimized out>) at startup_nat.c:151
#20 caml_main (argv=<optimized out>) at startup_nat.c:151
#21 0x00005555555b5f82 in main (argc=<optimized out>, argv=<optimized out>) at main.c:44

I will investigate this issue more, however I have no fix in the meantime.
I confirm however that not freeing other threads current_stacks do not trigger the fault at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants