|Anonymous | Login | Signup for a new account||2015-04-02 02:10 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005919||OCaml||OCamlbuild (the tool)||public||2013-02-12 22:13||2013-06-03 21:37|
|Status||closed||Resolution||unable to reproduce|
|Platform||Linux||OS||Debian Linux 6 64-bit||OS Version||Debian 6|
|Target Version||Fixed in Version|
|Summary||0005919: ocamlopt generates bad executable|
|Description||This 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.
|Tags||No tags attached.|
|Attached Files|| ocamlbug.tar.gz [^] (1,320,960 bytes) 2013-02-12 22:13|
ocamltest.tar.gz [^] (1,498,780 bytes) 2013-02-13 20:59
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?
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?
|the tarball you've attached cannot be opened. Please re-attach a right tarball.|
|So I should use the '-ocamlopt' option to make sure the right compiler is invoked?|
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.
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.
|The explanation given should suffice to fix the problem, so just closing this defect too.|
|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|
|Copyright © 2000 - 2011 MantisBT Group|