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

Ocaml toplevel segfault when using Pervasive functions #6444

Closed
vicuna opened this issue May 27, 2014 · 1 comment
Closed

Ocaml toplevel segfault when using Pervasive functions #6444

vicuna opened this issue May 27, 2014 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented May 27, 2014

Original bug ID: 6444
Reporter: Reventlov
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:27:41Z)
Resolution: not a bug
Priority: normal
Severity: crash
Platform: Linux
OS: Archlinux
OS Version: Up to date
Version: 4.01.0
Category: tools (ocaml{lex,yacc,dep,debug,...})

Bug description

Ocaml toplevel segfault when using the code below (the last line is syntactically incorrect but trigger the crash).

Steps to reproduce

let write_sys sys file =
let oc = Pervasives.open_out file in
Pervasives.output_value oc sys;
close_out oc;;

let read_sys file =
let ic = Pervasives.open_in file in
let sys = Pervasives.input_value ic in
close_in ic;
sys;;

write_sys (1,2) "/tmp/a";;
(read_sys "/tmp/a") (read_sys "/tmp/a");;

@vicuna
Copy link
Author

vicuna commented May 27, 2014

Comment author: @gasche

input_value has a polymorphic type, and it is the programmer's responsibility to give it the correct type (the type of the value that is being read). In this example you marshall a tuple that you unmarshall as a function, and "of course" this segfaults. It is not a bug. If you want a safe (un)pickling library, you should not use Marshal or {input,output}_value.

The documentation concisely says:

Warning: marshaling is currently not type-safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants