Skip to content

Commit b557594

Browse files
Henry-Lin-Ashipilev
authored andcommittedJul 22, 2024
8333728: ubsan: shenandoahFreeSet.cpp:1347:24: runtime error: division by zero
Reviewed-by: shade, rkennke
1 parent 34eea6a commit b557594

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,6 @@ void ShenandoahFreeSet::print_on(outputStream* out) const {
13511351
double ShenandoahFreeSet::internal_fragmentation() {
13521352
double squared = 0;
13531353
double linear = 0;
1354-
int count = 0;
13551354

13561355
idx_t rightmost = _partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator);
13571356
for (idx_t index = _partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator); index <= rightmost; ) {
@@ -1361,11 +1360,10 @@ double ShenandoahFreeSet::internal_fragmentation() {
13611360
size_t used = r->used();
13621361
squared += used * used;
13631362
linear += used;
1364-
count++;
13651363
index = _partitions.find_index_of_next_available_region(ShenandoahFreeSetPartitionId::Mutator, index + 1);
13661364
}
13671365

1368-
if (count > 0) {
1366+
if (linear > 0) {
13691367
double s = squared / (ShenandoahHeapRegion::region_size_bytes() * linear);
13701368
return 1 - s;
13711369
} else {

0 commit comments

Comments
 (0)