You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7479 Reporter: etc Status: resolved (set by @xavierleroy on 2017-02-19T16:50:01Z) Resolution: fixed Priority: normal Severity: minor Platform: Linux OS: arch linux OS Version: 4.7.2-1 Version: 4.02.3 Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1 Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1 Category: back end (clambda to assembly)
Bug description
Compiling with -pack and -a x.ml -o x.cma will succeed but when it's linked and used it will segfault.
I found that by changing the makefile to use -c x.ml -o x.cmo instead is how it's supposed to be done. Maybe compiling with -a shouldn't succeed when it's also -pack?
As far as I see the problem comes from
ocamlc -I pear -pack pear/grape.cma -o pear.cma
i.e. an attempt to build a pack from multiple compilation units found in grape.cma.
(By the way, -pack always produces a single object file, so the output should be "-o pear.cmo". But .cmo and .cma have different magic numbers so ocamlc is not confused.)
Here we get a pear.cmi that contains
module Pear : sig module Grape : sig ... end end
but a pear.cmo/pear.cma that contains
0 CONST0
1 MAKEBLOCK1 0
3 SETGLOBAL Pear
i.e. that sets Pear = struct end (the empty module). Hence the segfault when Pear is used in Main.
Also: you write "Compiling with -pack and -a x.ml -o x.cma... will segfault", but this is not what your repro is testing. Are there other problems with the combination you describe but do not reproduce?
Original bug ID: 7479
Reporter: etc
Status: resolved (set by @xavierleroy on 2017-02-19T16:50:01Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: Linux
OS: arch linux
OS Version: 4.7.2-1
Version: 4.02.3
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: back end (clambda to assembly)
Bug description
Compiling with
-pack
and-a x.ml -o x.cma
will succeed but when it's linked and used it will segfault.I found that by changing the makefile to use
-c x.ml -o x.cmo
instead is how it's supposed to be done. Maybe compiling with -a shouldn't succeed when it's also -pack?Steps to reproduce
Clone this git repository: https://github.com/Charlesetc/ocaml-segfault/
$ make
$ ./test.byte
Additional information
On the same git repo, there's a "success" branch https://github.com/Charlesetc/ocaml-segfault/tree/success, which has a change in the command that actually works. Thanks for taking a look!
The text was updated successfully, but these errors were encountered: