|Anonymous | Login | Signup for a new account||2014-04-21 16:53 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005942||OCaml||OCaml runtime system||public||2013-03-11 23:29||2013-12-16 14:29|
|Target Version||4.01.1+dev||Fixed in Version|
|Summary||0005942: Weak hash of serialized closures|
|Description||Usually, when you serialize a closure with one program, it is impossible to unserialize it with a different program, and you expect to obtain a runtime exception like: Failure("input_value: unknown code module FAE2E4BE7A3AE0091CF3043126B2CC65")|
But, when two programs differs only by their data segments (see the attached example), it is possible to marshal a closure with the first program and to unmarshal it with the second program. Obviously, if you try to call the invalid unserialized closue, execution results in the famous "segmentation fault".
This bug is reproducible with ocamlc and ocamlopt.
The problem is that the hash sum stored in the marshalled closure is only computed with the code segment and not with the data segment.
I wrote a patch to fix it.
|Steps To Reproduce||With attached x.ml and y.ml, run:|
ocamlopt x.ml -o x
ocamlopt y.ml -o y
Do not import "data", ok
Segmentation fault (core dumped)
|Additional Information||Fixed by the attached patch: ocaml-4.00.1-data-marsh.diff.|
Remark: dynlink is ok because the entire dynlinked files are hashed.
So, I just modify byterun and asmrun.
|Attached Files|| ocaml-4.00.1-data-marsh.tgz [^] (2,649 bytes) 2013-03-11 23:29|
ocaml-4.00.1-data-marsh.diff [^] (9,866 bytes) 2013-03-11 23:57 [Show Content]
edited on: 2013-03-12 00:11
I took the liberty to upload the patch independently from the archive, for eventual reviewers that would be more comfortable having a look directly inside Mantis.
I could reproduce the bug with 3.12.1, 32 bits, but not 4.00.1 64 bits: as the data fields should be of the same size (or at least aligned), on a 64 bits machine you need to shorten the list in y.ml to two integers rather than four to observe the segfault.
|Important, but too risky to merge just before a release, I'd say.|
|2013-03-11 23:29||bvaugon||New Issue|
|2013-03-11 23:29||bvaugon||File Added: ocaml-4.00.1-data-marsh.tgz|
|2013-03-11 23:57||gasche||File Added: ocaml-4.00.1-data-marsh.diff|
|2013-03-12 00:03||gasche||Note Added: 0008959|
|2013-03-12 00:03||gasche||Status||new => confirmed|
|2013-03-12 00:11||gasche||Note Edited: 0008959||View Revisions|
|2013-07-12 09:41||doligez||Target Version||=> 4.01.0+dev|
|2013-07-22 12:45||frisch||Note Added: 0009822|
|2013-07-22 12:45||frisch||Target Version||4.01.0+dev => 4.01.1+dev|
|2013-12-16 14:29||doligez||Tag Attached: patch|
|Copyright © 2000 - 2011 MantisBT Group|