-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Functions from weak are breaking all marking invariants on ephemerons #9424
Merged
damiendoligez
merged 2 commits into
ocaml:trunk
from
bobot:fix_Ephemeron_segfault_with_missing_write_barrier
Jul 20, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
(* TEST | ||
*) | ||
|
||
let debug = false | ||
|
||
open Printf | ||
open Ephemeron | ||
|
||
let empty = ref 0 | ||
let make_ra ~size = Array.init size (fun _ -> ref 1) [@@inline never] | ||
let make_ephes ~size = Array.init size (fun _ -> Ephemeron.K1.create ()) [@@inline never] | ||
|
||
let test ~size ~slice = | ||
let keys1 = make_ra ~size in | ||
let keys2 = make_ra ~size in | ||
let datas1 = make_ra ~size in | ||
let datas2 = make_ra ~size in | ||
let ephe1 = make_ephes ~size in | ||
let ephe2 = make_ephes ~size in | ||
if debug then Gc.set { (Gc.get ()) with Gc.verbose = 0x3 }; | ||
(** Fill ephe.(i )from key.(i) to data.(i) *) | ||
for i=0 to size-1 do Ephemeron.K1.set_key ephe1.(i) keys1.(i); done; | ||
for i=0 to size-1 do Ephemeron.K1.set_data ephe1.(i) datas1.(i); done; | ||
for i=0 to size-1 do Ephemeron.K1.set_key ephe2.(i) keys2.(i); done; | ||
for i=0 to size-1 do Ephemeron.K1.set_data ephe2.(i) datas2.(i); done; | ||
(** Push everything in the major heap *) | ||
if debug then Printf.eprintf "Start minor major\n%!"; | ||
Gc.minor (); | ||
Gc.major (); | ||
if debug then Printf.eprintf "start emptying\n%!"; | ||
for i=0 to size-1 do keys1.(i) <- empty; done; | ||
for i=0 to size-1 do datas1.(i) <- empty; done; | ||
(** The emptying is done during a major so keys and data are kept alive by the | ||
assignments. Restart a new major *) | ||
Gc.major (); | ||
if debug then Printf.eprintf "Start checking state\n%!"; | ||
(** Fill the ephemeron with an alive key *) | ||
if debug then Printf.eprintf "Start replacing dead key into alive one\n%!"; | ||
(* Printf.eprintf "put in set (2) %i\n%!" (Gc.major_slice (10*4*slice*6)); *) | ||
for i=0 to size-1 do | ||
ignore (Gc.major_slice (4)); | ||
if debug then Printf.eprintf "@%!"; | ||
Ephemeron.K1.blit_data ephe1.(i) ephe2.(i); | ||
if debug && 0 = i mod (size / 10) then Printf.eprintf "done %5i/%i\n%!" i size; | ||
done; | ||
if debug then Printf.eprintf "end\n%!"; | ||
(** Finish all, assertion in clean phase should not find a dangling data *) | ||
Gc.full_major (); | ||
let r = ref 0 in | ||
if debug then | ||
for i=0 to size-1 do | ||
if Ephemeron.K1.check_data ephe2.(size-1-i) then incr r; | ||
if 0 = i mod (size / 10) then Printf.eprintf "done %5i/%i %i\n%!" i size !r; | ||
done; | ||
(* keep the arrays alive *) | ||
assert (Array.length keys1 = size); | ||
assert (Array.length keys2 = size); | ||
assert (Array.length datas1 = size); | ||
assert (Array.length datas2 = size); | ||
assert (Array.length ephe1 = size); | ||
assert (Array.length ephe2 = size) | ||
[@@inline never] | ||
|
||
let () = | ||
test ~size:1000 ~slice:5; | ||
test ~size:1000 ~slice:10; | ||
test ~size:1000 ~slice:15 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use
Is_white_during_mark
here, because if it's not white thencaml_darken
will do nothing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the comment,
Is_white_during_mark
is used and on something different than what is darken.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant using
Is_white_during_mark
instead of theField(...) != caml_ephe_none
test. But it doesn't seem important anyway.