Skip to content

Instantly share code, notes, and snippets.

@jbachorik
jbachorik / HCRRepro.java
Created August 6, 2026 16:02
J9 OSR buffer corruption by SIGPROF signal frames - reproducer for eclipse-openj9/openj9#24487
import java.lang.instrument.Instrumentation;
import java.lang.instrument.ClassFileTransformer;
import java.security.ProtectionDomain;
import java.util.concurrent.atomic.AtomicInteger;
public class HCRRepro {
public static volatile boolean running = true;
static volatile long counter = 0;
static Instrumentation inst;
static volatile int retransCount = 0;
@jbachorik
jbachorik / Main.java
Created August 5, 2026 09:41
Standalone reproducer: OpenJ9 AsyncGetCallTrace self-deadlock on jitArtifactMonitor
/*
* Standalone driver for the OpenJ9 AsyncGetCallTrace self-deadlock repro.
* No Datadog code -- generic JNI/JVMTI only.
*
* Workload: many threads continuously allocate a fresh monitor object,
* synchronize on it and wait() with a short timeout (forcing an
* inflate-then-deflate cycle every iteration), while a dedicated thread
* forces frequent GC. Combined with the native agent's 1ms-period
* AsyncGetCallTrace sampling (see agent.c), this reliably lands a sample
* signal on a thread that is inside OpenJ9's JIT-artifact-monitor critical
@jbachorik
jbachorik / fosdem_2025_resources.md
Created January 28, 2025 09:46
FOSDEM 2025: Advancing Java Profiling
#include <jvmti.h>
#include <jni.h>
#include <string.h>
static jvmtiEnv *jvmti = NULL;
static jclass outOfMemoryErrorClass = NULL;
void check_exact_exception_type(JNIEnv *jni_env, jobject exception) {
jclass exceptionClass = (*jni_env)->GetObjectClass(jni_env, exception);
if ((*jni_env)->IsSameObject(jni_env, exceptionClass, outOfMemoryErrorClass)) {
#! /bin/bash
# see http://hirt.se/images/openjdk/ilw.png
if [ $# -ne 1 ]; then
echo "Provide ILW score"
exit 1
fi
priority="P5"
import org.openjdk.btrace.core.BTraceUtils;
import org.openjdk.btrace.core.annotations.*;
import org.openjdk.btrace.core.jfr.JfrEvent;
import static org.openjdk.btrace.core.BTraceUtils.*;
import static org.openjdk.btrace.core.BTraceUtils.Jfr.*;
@BTrace
public class TracePreparedQuery {
@Event(
name = "jdbc.PreparedQuery",

Start a JVM with active recording which gets persisted to <path>

java -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=1g,filename=<path> ...

gunther:0.0.0-JFR jbachorik$ ./bin/btrace -lp anagrams.jar
btrace INFO: Attaching BTrace to PID: 32199
1: 6c83f579-2624-4acb-9cbf-1f59b3aa2076 [org.openjdk.btrace.runtime.aux.AllMethods1]
import org.openjdk.btrace.core.BTraceUtils;
import org.openjdk.btrace.core.annotations.*;
import org.openjdk.btrace.core.jfr.JfrEvent;
import static org.openjdk.btrace.core.BTraceUtils.*;
import static org.openjdk.btrace.core.BTraceUtils.Jfr.*;
@BTrace public class JfrEventsProbe {
@Event(
name = "CustomEvent",
label = "Custom Event",