Compare commits

...

3 Commits

Author SHA1 Message Date
Vitaly Provodin
5438a83c83 fixup! JBR-9238 Introduce distinct test groups for Vulkan runs 2025-08-29 14:44:20 +04:00
Vitaly Provodin
230ef3a2b0 JBR-9274 add a test against streaming output for attach API 2025-08-29 14:22:38 +04:00
Vitaly Provodin
616b476674 JBR-9274 turn off streaming output for attach API by default 2025-08-29 14:22:38 +04:00
5 changed files with 197 additions and 11 deletions

View File

@@ -172,8 +172,8 @@ volatile AttachListenerState AttachListener::_state = AL_NOT_INITIALIZED;
AttachAPIVersion AttachListener::_supported_version = ATTACH_API_V1;
// Default is true (if jdk.attach.vm.streaming property is not set).
bool AttachListener::_default_streaming_output = true;
// Default is false (if jdk.attach.vm.streaming property is not set).
bool AttachListener::_default_streaming_output = false;
static bool get_bool_sys_prop(const char* name, bool default_value, TRAPS) {
ResourceMark rm(THREAD);

View File

@@ -63,8 +63,10 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
static {
String s = VM.getSavedProperty("jdk.attach.allowAttachSelf");
ALLOW_ATTACH_SELF = "".equals(s) || Boolean.parseBoolean(s);
// For now the default is false because it makes jstack hang with
// buffer overflow on lengthy outputs, which occur often in automatic tests.
String s2 = VM.getSavedProperty("jdk.attach.allowStreamingOutput");
ALLOW_STREAMING_OUTPUT = !("false".equals(s2));
ALLOW_STREAMING_OUTPUT = "".equals(s2) || Boolean.parseBoolean(s2);
}
private final boolean selfAttach;

View File

@@ -447,14 +447,8 @@ jdk_editpad = \
jbr_all = \
jb \
-jb/java/awt/wayland/VulkanBlitTest.java \
-jb/java/awt/wayland/RobotGetPixelsTest.java \
-jb/java/awt/wayland/ImageTransformTest.java \
-jb/java/awt/wayland/VulkanGCCompatibilityTest.java \
-jb/java/awt/wayland/RobotGetPixelTest.java \
-jb/java/awt/wayland/RobotGetOOBPixelsTest.java \
-jb/java/awt/wayland/VulkanCompositeTest.java \
-jb/java/awt/wayland/VulkanMaskFillTest.java
-jb/java/awt/vulkan \
-jb/java/awt/wayland/vulkan \
jdk_desktop = \
:jdk_desktop_part1 \
@@ -823,6 +817,7 @@ jdk_since_checks = \
jdk_awt_wayland = \
:jdk_awt \
jb/java/awt/wayland \
-jb/java/awt/wayland/vulkan \
jb/java/awt/Focus/ActivateAfterHide.java \
-com/apple/eawt \
-com/apple/laf \

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2025 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import java.util.concurrent.TimeUnit;
/**
* @test
* @bug 8354460
* @summary <code>JStackHangTest</code> verifies the streaming output of the attach API. It launches
* <code>JStackLauncher</code> in a child VM and ensures <code>jstack</code> does not hang.
* @library /test/lib
* @compile JStackLauncher.java
* @run main/othervm JStackHangTest
*/
public class JStackHangTest {
static final int JSTACK_WAIT_TIME = JStackLauncher.JSTACK_WAIT_TIME * 2;
public static final int CODE_NOT_RETURNED = 100;
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(JStackLauncher.class.getName());
Process process = ProcessTools.startProcess("Child", pb);
OutputAnalyzer outputAnalyzer = new OutputAnalyzer(process);
int returnCode;
if (!process.waitFor(JSTACK_WAIT_TIME, TimeUnit.MILLISECONDS)) {
System.out.println("jstack did not complete in " + JSTACK_WAIT_TIME + " ms.");
System.out.println("killing all the jstack processes");
ProcessTools.executeCommand("killall", "-9", "jstack");
returnCode = CODE_NOT_RETURNED;
} else {
returnCode = outputAnalyzer.getExitValue();
System.out.println("returnCode = " + returnCode);
}
if (returnCode == CODE_NOT_RETURNED)
throw new RuntimeException("jstack: failed to start or hanged");
else
System.out.println("jstack: completed successfully");
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2025 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
/**
* <code>JStackLauncher</code> is used to launch <code>jstack</code> in the test of streaming output for the attach API
*
*/
public class JStackLauncher {
public static final String JAVA_HOME = System.getProperty("java.home");
public static final String JAVA_BIN = JAVA_HOME + File.separator + "bin";
public static final String JSTACK_PATH = JAVA_BIN + File.separator + "jstack";
static final int JSTACK_WAIT_TIME = 5000;
static final int THREAD_COUNT = 10;
static final int STACK_DEPTH = 100;
static Process process;
static CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
public static void main(String[] args) throws InterruptedException {
// Create threads with deep stacks
List<Thread> threads = createManyThreadsWithDeepStacks();
// Run jstack against current process
System.out.println("Starting jstack...");
try {
process = new ProcessBuilder(JSTACK_PATH, String.valueOf(ProcessHandle.current().pid())).start();
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println("Reading jstack output...");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
Stream<String> output = reader.lines();
output.forEach(System.out::println);
if (!process.waitFor(JSTACK_WAIT_TIME, TimeUnit.MILLISECONDS)) {
process.destroyForcibly();
throw new RuntimeException("jstack failed to complete in " + JSTACK_WAIT_TIME + " ms.");
}
threads.forEach(Thread::interrupt);
}
public static List<Thread> createManyThreadsWithDeepStacks() throws InterruptedException {
List<Thread> threads = new ArrayList<>();
for (int threadIndex = 0; threadIndex < THREAD_COUNT; threadIndex++) {
System.out.println("Creating thread " + threadIndex);
Thread t = new DeepStackThread(threadIndex);
t.start();
threads.add(t);
}
latch.await();
return threads;
}
static class DeepStackThread extends Thread {
DeepStackThread(int index) {
super.setName("DeepStackThread-" + index);
}
@Override
public synchronized void run() {
try {
createDeepStack(STACK_DEPTH);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println("Thread " + getName() + " exiting");
}
void createDeepStack(int depth) throws InterruptedException {
if (depth > 0) {
createDeepStack(depth - 1);
} else {
latch.countDown();
Thread.sleep(Long.MAX_VALUE);
}
}
}
}