Skip to content

Commit 69cfa9c

Browse files
author
Kim Barrett
committedJan 19, 2022
8273383: vmTestbase/vm/gc/containers/Combination05/TestDescription.java crashes verifying length of DCQS
Reviewed-by: tschatzl, sjohanss
1 parent af6c9ab commit 69cfa9c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,13 @@ void G1DirtyCardQueueSet::enqueue_completed_buffer(BufferNode* cbn) {
123123
// Increment _num_cards before adding to queue, so queue removal doesn't
124124
// need to deal with _num_cards possibly going negative.
125125
size_t new_num_cards = Atomic::add(&_num_cards, buffer_size() - cbn->index());
126-
_completed.push(*cbn);
126+
{
127+
// Perform push in CS. The old tail may be popped while the push is
128+
// observing it (attaching it to the new buffer). We need to ensure it
129+
// can't be reused until the push completes, to avoid ABA problems.
130+
GlobalCounter::CriticalSection cs(Thread::current());
131+
_completed.push(*cbn);
132+
}
127133
if ((new_num_cards > process_cards_threshold()) &&
128134
(_primary_refinement_thread != NULL)) {
129135
_primary_refinement_thread->activate();

0 commit comments

Comments
 (0)
Please sign in to comment.