Prevent static allocations in pr5233 test

master
Pierre Chambart 2016-01-28 18:01:24 +01:00
parent ce2ba592a7
commit 9aef55ed9c
1 changed files with 14 additions and 11 deletions

View File

@ -45,18 +45,21 @@ let check o =
printf " ok\n";
;;
Weak.set !smuggle 0 (Some (String.make size ' '));;
let f () =
Weak.set !smuggle 0 (Some (String.make size ' '));
(* Check the data just to make sure. *)
check (Weak.get !smuggle 0);;
(* Check the data just to make sure. *)
check (Weak.get !smuggle 0);
(* Get a dangling pointer in W. *)
Gc.full_major ();;
(* Get a dangling pointer in W. *)
Gc.full_major ();
(* Fill the heap with other stuff. *)
let rec fill n accu = if n = 0 then accu else fill (n-1) (123 :: accu);;
let r = fill ((Gc.stat ()).Gc.heap_words / 3) [];;
Gc.minor ();;
(* Fill the heap with other stuff. *)
let rec fill n accu = if n = 0 then accu else fill (n-1) (123 :: accu) in
let _r : int list = fill ((Gc.stat ()).Gc.heap_words / 3) [] in
Gc.minor ();
(* Now follow the dangling pointer and exhibit the problem. *)
check (Weak.get !smuggle 0);;
(* Now follow the dangling pointer and exhibit the problem. *)
check (Weak.get !smuggle 0)
let () = (f [@inlined never]) ()