Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007479OCamlback end (clambda to assembly)public2017-02-10 00:402017-02-19 17:50
Reporteretc 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformLinuxOSarch linux OS Version4.7.2-1
Product Version4.02.3 
Target Version4.05.0 +dev/beta1/beta2/beta3/rc1Fixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007479: Compiling with '-pack' and '-a x.ml -o x.cma' succeeds and but the executable segfaults
DescriptionCompiling 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 ReproduceClone this git repository: https://github.com/Charlesetc/ocaml-segfault/ [^]

$ make
$ ./test.byte
Additional InformationOn 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!
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0017346)
xleroy (administrator)
2017-02-19 17:18
edited on: 2017-02-19 17:19

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.

(0017347)
xleroy (administrator)
2017-02-19 17:20

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?
(0017348)
xleroy (administrator)
2017-02-19 17:50

Fixed the easy way in 4.05: ocamlc -pack rejects arguments that are .cma files, and ocamlopt -pack rejects arguments that are .cmxa files.

- Issue History
Date Modified Username Field Change
2017-02-10 00:40 etc New Issue
2017-02-19 17:18 xleroy Note Added: 0017346
2017-02-19 17:18 xleroy Status new => confirmed
2017-02-19 17:18 xleroy Target Version => undecided
2017-02-19 17:19 xleroy Note Edited: 0017346 View Revisions
2017-02-19 17:20 xleroy Note Added: 0017347
2017-02-19 17:50 xleroy Note Added: 0017348
2017-02-19 17:50 xleroy Status confirmed => resolved
2017-02-19 17:50 xleroy Resolution open => fixed
2017-02-19 17:50 xleroy Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-02-19 17:50 xleroy Target Version undecided => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-02-23 16:35 doligez Category OCaml backend (code generation) => Back end (clambda to assembly)
2017-02-23 16:44 doligez Category Back end (clambda to assembly) => back end (clambda to assembly)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker