Skip to content

Commit

Permalink
fix for ocaml#9853
Browse files Browse the repository at this point in the history
  • Loading branch information
damiendoligez committed Feb 12, 2021
1 parent 9f51fac commit 2925829
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Working version
- #10136: Minor clean-ups in runtime/io.c and runtime/caml/io.h
(Xavier Leroy, review by David Allsopp and Guillaume Munch-Maccagnoni)

- #xxxxx: Fix a segfault in a corner case of compaction (reported in #9853)
(Damien Doligez, report by Sadiq Jaffer, review by xxxx)

### Code generation and optimizations:

- #9876: do not cache the young_limit GC variable in a processor register.
Expand Down
5 changes: 1 addition & 4 deletions runtime/compact.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ static char *compact_allocate (mlsize_t size)
{
char *chunk, *adr;

while (Chunk_size (compact_fl) - Chunk_alloc (compact_fl) <= Bhsize_wosize (3)
&& Chunk_size (Chunk_next (compact_fl))
- Chunk_alloc (Chunk_next (compact_fl))
<= Bhsize_wosize (3)){
while (Chunk_size(compact_fl) - Chunk_alloc(compact_fl) <= Bhsize_wosize(0)){
compact_fl = Chunk_next (compact_fl);
}
chunk = compact_fl;
Expand Down
10 changes: 10 additions & 0 deletions testsuite/tests/regression/pr9853/compaction_corner_case.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(* TEST *)

(* Compaction crash when there is only one heap chunk and it is fully used. *)
let c = ref []

let () =
for i = 0 to 25000 do
c := 0 :: !c;
Gc.compact ()
done

0 comments on commit 2925829

Please sign in to comment.