ocaml/implicit_close test: collect all currently unreachable blocks

Fixes failing implice_close test on OCaml 5.

RWMJ:

I adjusted this patch so that we continue to call Gc.compact on
exiting the test, to move all of the heap (hopefully revealing flaws
in the bindings).  This only works on OCaml <= 4, but Gc.compact may
be fixed/reimplemented later in the 5.x series.

Please see also the lengthy discussion of this patch upstream:
https://listman.redhat.com/archives/libguestfs/2023-May/thread.html#31639
https://listman.redhat.com/archives/libguestfs/2023-June/thread.html#31709
https://discuss.ocaml.org/t/ocaml-heap-fsck-and-forcing-collection-of-unreachable-objects/12281/1

(cherry picked from commit 1274452d22)
This commit is contained in:
Jürgen Hötzel
2023-05-27 15:32:36 +02:00
committed by Richard W.M. Jones
parent 744a257083
commit 8aafa0631b

View File

@@ -30,7 +30,7 @@ let () =
*)
(* This should cause the GC to close the handle. *)
let () = Gc.compact ()
let () = Gc.full_major ()
let () = assert (!close_invoked = 1)