Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005919OCaml-for ocamlbuild use 22:132013-06-03 21:37
Assigned Tomeyer 
StatusclosedResolutionunable to reproduce 
PlatformLinuxOSDebian Linux 6 64-bitOS VersionDebian 6
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005919: ocamlopt generates bad executable
DescriptionThis is related to [^]

But I am able to produce both good and bad executables. The only difference is the setting of "PATH" environment variable. Here is what I observed: suppose my ocaml is installed at /<path_to>/ocaml

If I add '/<path_to>/ocaml/bin' to my PATH and then invoke ocamlbuild.native, it creates an executable that seg faults. If I unset the PATH and use '/<path_to>/ocaml/bin/ocamlbuild' to build the target, it is a good executable.
TagsNo tags attached.
Attached Filesgz file icon ocamlbug.tar.gz [^] (1,320,960 bytes) 2013-02-12 22:13
gz file icon ocamltest.tar.gz [^] (1,498,780 bytes) 2013-02-13 20:59

- Relationships

-  Notes
zhihan (reporter)
2013-02-13 15:57

I did a little bit further investigation myself. I used readelf to disassemble the two files. Among the differences, this one might be related.
In the 'bad' file produced from ocamlopt, the relocation address of 'strcmp' and 'strcpy' are placed in the '.rela.dyn' section, while in the 'good' file these relocations are placed in the '.rela.plt' section.

According to resources on the internet, '.rela.plt' should hold relocation addresses for C functions and '.rela.dyn' should hold for data. In this regard, the relocation addresses of 'strcpy' is placed in the wrong section. Might it be the cause the seg fault?
meyer (developer)
2013-02-13 20:55

The reason for that is that ocamlbuild might pick the wrong compiler. Ocamlbuild tries to use not the compiler on path but the one it's being rooted.

if /usr/local/bin/ocamlbuild.native is present it will always pick the /usr/local/ocamlc and not the one pointed by PATH.

Please double check if you didn't hit that problem, perhaps you have several incompatible ocaml installations.

What will happen if you compile the program manually?
meyer (developer)
2013-02-13 20:56

the tarball you've attached cannot be opened. Please re-attach a right tarball.
zhihan (reporter)
2013-02-13 21:00

So I should use the '-ocamlopt' option to make sure the right compiler is invoked?
meyer (developer)
2013-02-13 21:53

Unfortunately yes, that's the only way you can change it.

The trunk of the toolchain, if you wish to try dev version, contains also -which flag which will tell you what's being picked up. You can also use -verbose 100 which will show you the commands being invoked. Please make sure if you swap a compiler to use -clean flag before.

If you are not forced to use 3.12.1 compiler, I'd strongly advise to try 4.00.1. The easiest way to get the system working is via OPAM.
xleroy (administrator)
2013-03-24 12:02

So, do we have enough info on this PR to see if something needs to be done? W. Meyer wisely suggests to use a clean 4.00.1 installation. If this is enough to solve the problem, I move to close this PR.
meyer (developer)
2013-06-03 21:37

The explanation given should suffice to fix the problem, so just closing this defect too.

- Issue History
Date Modified Username Field Change
2013-02-12 22:13 zhihan New Issue
2013-02-12 22:13 zhihan File Added: ocamlbug.tar.gz
2013-02-13 15:57 zhihan Note Added: 0008839
2013-02-13 20:55 meyer Note Added: 0008840
2013-02-13 20:56 meyer Note Added: 0008841
2013-02-13 20:59 zhihan File Added: ocamltest.tar.gz
2013-02-13 21:00 zhihan Note Added: 0008842
2013-02-13 21:53 meyer Note Added: 0008843
2013-03-24 12:02 xleroy Note Added: 0009004
2013-03-24 12:02 xleroy Status new => feedback
2013-04-15 12:22 xleroy Status feedback => resolved
2013-04-15 12:22 xleroy Resolution open => unable to reproduce
2013-06-03 21:37 meyer Note Added: 0009385
2013-06-03 21:37 meyer Status resolved => closed
2013-06-03 21:37 meyer Assigned To => meyer
2017-02-23 16:34 doligez Category OCamlbuild (the tool) => for ocamlbuild use [^]
2017-02-23 16:44 doligez Category for ocamlbuild use [^] => -for ocamlbuild use [^]

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker