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

input_value / heap compaction incompatibility #7970

Closed
vicuna opened this issue Dec 11, 2002 · 2 comments
Closed

input_value / heap compaction incompatibility #7970

vicuna opened this issue Dec 11, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 11, 2002

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

Bug description

Full_Name: Martin Jambon
Version: 3.06 (and 3.04)
OS: i386-Linux (kernel 2.2.20 and 2.4.9)
Submission from: pc-bioinfo1.ibcp.fr (193.51.160.63)

The following program ends with Segmentation fault, with ocaml, ocamlc
and ocamlopt on i386/Linux:

(***************** START ***********************)
type t = { id : int;
mutable next : t list }

let create_chain number_of_cells =
let rec loop cell i =
let new_cell = { id = i;
next = [cell] } in
if i = 0 then new_cell
else loop new_cell (pred i) in
let rec first = { id = 0;
next = [] } in
let last = loop first number_of_cells in
last

let create_data () =
Array.init
60000
(fun _ -> create_chain 10)

let test_data () =
let data = create_data () in
let s = Marshal.to_string data [] in
ignore (Marshal.from_string s 0)

let _ =
Gc.set { (Gc.get ()) with Gc.verbose = 0x010 };
test_data ();
Gc.compact ()
(************************** END OF PROGRAM *******************************)

This problem occurs when large data are loaded using input_value or
Marshal.from_* functions.
The parameter size of the array (60000) may be changed to some other
close value with different results. Here, "+" indicates successful exit
(0) and "-" indicates segmentation fault:

59990 +
59991 -
59992 -
59993 +
59994 -
59995 -
59996 +
59997 -
59998 -
59999 +
60000 -

The problem doesn't seem to appear with values below 59900.

output_value followed input_value regenerates an identical file.
The data produced by input_value seems correct but causes malfunctions
during heap compactions. Whether the compactions are automatically
triggered (in OCaml 3.06) or not does not change the result. The
following code will crash during an automatic heap compaction (when i = 2):

let _ =
Gc.set { (Gc.get ()) with Gc.verbose = 0x010 };
for i = 1 to 10; do
print_int i; print_newline ();
test_data ()
done

In practice, I have files containing large and complex marshaled data,
and the crash occurs when the size of the marshaled result (file)
exceeds 10MB (5 out of 2000 tested cases).

@vicuna
Copy link
Author

vicuna commented Dec 12, 2002

Comment author: administrator

Full_Name: Martin Jambon
In practice, I have files containing large and complex marshaled data,
and the crash occurs when the size of the marshaled result (file)
exceeds 10MB (5 out of 2000 tested cases).

There are some inconsistent assumptions between the code for "intern"
and the compactor. I have fixed them in the current working version
(3.06+20).

You can work around this bug by disabling compaction in your program,
or I can provide a patch.

Thanks for the well-delimited bug report.

-- Damien

@vicuna vicuna closed this as completed Dec 12, 2002
@vicuna
Copy link
Author

vicuna commented Dec 17, 2002

Comment author: administrator

On Thu, 12 Dec 2002, Damien Doligez wrote:

There are some inconsistent assumptions between the code for "intern"
and the compactor. I have fixed them in the current working version
(3.06+20).

You can work around this bug by disabling compaction in your program,
or I can provide a patch.

Great job! Thanks a lot!

Everything works fine for my program with the working version.

Martin

@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