Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with marshal and thread-enabled toplevel #7806

Closed
vicuna opened this issue Oct 25, 2002 · 2 comments
Closed

problem with marshal and thread-enabled toplevel #7806

vicuna opened this issue Oct 25, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 25, 2002

Original bug ID: 1458
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

When I marshal a simple value to a file and read it back again, from a
bytecode enabled toplevel, i get a segfault.
The simple code is as such:

type mytype = T of (float * float)
let fd = open_out_bin "/tmp/file.mld"
let myval = T (1.0, 1.0)
Marshal.to_channel fd myval []
close_out fd

let fd = open_in_bin "/tmp/file.mld"
let myval = (Marshal.from_channel fd: mytype)
match myval with
T bla -> bla

In fact, entering the code line-by-line in the toplevel shows that the
type of myval is not recognized:

let myval = (Marshal.from_channel fd : mytype)

val myval : mytype =

The toplevel is made as such:
%ocamlmktop -thread /usr/lib/ocaml/threads/unix.cma
/usr/lib/ocaml/threads/threads.cma -o ocaml-th

Ocaml 3.06, RH7.2

best regards
henri


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

@vicuna
Copy link
Author

vicuna commented Oct 26, 2002

Comment author: administrator

Fixed 2002-10-26 by XL

@vicuna vicuna closed this as completed Oct 26, 2002
@vicuna
Copy link
Author

vicuna commented Oct 28, 2002

Comment author: administrator

When I marshal a simple value to a file and read it back again, from a
bytecode enabled toplevel, i get a segfault.
The simple code is as such:

type mytype = T of (float * float)
let fd = open_out_bin "/tmp/file.mld"
let myval = T (1.0, 1.0)
Marshal.to_channel fd myval []
close_out fd

let fd = open_in_bin "/tmp/file.mld"
let myval = (Marshal.from_channel fd: mytype)
match myval with
T bla -> bla

The bytecode thread-safe version of Marshal.from_channel is indeed
broken. A simple workaround is to use Pervasives.input_value, which
is functionally equivalent but not broken. The fix that is now in the
CVS development version is simply to replace the wrong definition of
from_channel in otherlibs/threads/marshal.ml by the simpler and more
correct

let from_channel = Pervasives.input_value

  • Xavier Leroy

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant