8373298: Test java/foreign/TestBufferStackStress.java timed out then completed

Reviewed-by: jpai, jvernee
This commit is contained in:
Per Minborg 2026-04-22 13:41:15 +00:00
parent 7e26bc6d4c
commit 832bd9cdc3
3 changed files with 14 additions and 10 deletions

View File

@ -744,8 +744,6 @@ jdk/jfr/jvm/TestWaste.java 8371630 generic-
# jdk_foreign
java/foreign/TestBufferStackStress.java 8350455 macosx-all
############################################################################
# Client manual tests

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,12 @@
/*
* @test
* @modules java.base/jdk.internal.foreign
* @build NativeTestHelper TestBufferStackStress
* @library /test/lib
* @run junit TestBufferStackStress
*/
import jdk.internal.foreign.BufferStack;
import jdk.test.lib.Platform;
import org.junit.jupiter.api.Test;
import java.lang.foreign.Arena;
@ -40,17 +41,23 @@ import java.util.stream.IntStream;
import static java.lang.foreign.ValueLayout.*;
import static java.time.temporal.ChronoUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
public class TestBufferStackStress {
final class TestBufferStackStress {
@Test
public void stress() throws InterruptedException {
void stress() throws InterruptedException {
if (Platform.isOSX()) {
// 8350455 was only fixed in macOS versions 26 or higher
assumeFalse(Platform.getOsVersionMajor() < 26, "Unsupported OS version: " + Platform.getOsVersionMajor());
}
BufferStack stack = BufferStack.of(256, 1);
Thread[] vThreads = IntStream.range(0, 1024).mapToObj(_ ->
Thread[] vThreads = IntStream.range(0, 512).mapToObj(_ ->
Thread.ofVirtual().start(() -> {
long threadId = Thread.currentThread().threadId();
while (!Thread.interrupted()) {
for (int i = 0; i < 1_000_000; i++) {
for (int i = 0; i < 500_000; i++) {
try (Arena arena = stack.pushFrame(JAVA_LONG.byteSize(), JAVA_LONG.byteAlignment())) {
// Try to assert no two vThreads get allocated the same stack space.
MemorySegment segment = arena.allocate(JAVA_LONG);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,6 @@
*
* @bug 8356114 8356658
* @modules java.base/jdk.internal.foreign
* @build NativeTestHelper TestBufferStackStress2
* @run junit/timeout=480 TestBufferStackStress2
*/