{"record":{"id":"3016d8031f83fa67","repo":"oracle/graal","slug":"failed-to-initialize-threads-for-papi-s","errorCode":null,"errorMessage":"Failed to initialize threads for PAPI %s\n","messagePattern":"Failed to initialize threads for PAPI (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.papibridge/src/papibridge.c","lineNumber":44,"sourceCode":"#include <jni.h>\n#include <papi.h>\n#include <pthread.h>\n#include <stdlib.h>\n\n/**\n * Initializes the PAPI library.\n *\n * @return JNI_TRUE if the initialization is successful, JNI_FALSE otherwise.\n */\nJNIEXPORT jboolean JNICALL Java_jdk_graal_compiler_hotspot_replaycomp_HardwarePerformanceCounters_initialize(JNIEnv *env, jclass cls) {\n    printf(\"Initializing PAPI\\n\");\n    int retval = PAPI_library_init(PAPI_VER_CURRENT);\n    if (retval != PAPI_VER_CURRENT) {\n        fprintf(stderr, \"Failed to initialize PAPI %s\\n\", PAPI_strerror(retval));\n        return JNI_FALSE;\n    }\n    if ((retval = PAPI_thread_init(pthread_self)) != PAPI_OK) {\n        fprintf(stderr, \"Failed to initialize threads for PAPI %s\\n\", PAPI_strerror(retval));\n        return JNI_FALSE;\n    }\n    return JNI_TRUE;\n}\n\n/**\n * Creates a new PAPI event set and adds the specified events to it.\n *\n * @param env The JNI environment.\n * @param cls The Java class that this native method belongs to.\n * @param eventNames An array of event names to be added to the event set.\n *\n * @return The handle of the created event set, or PAPI_NULL if an error occurs.\n */\nJNIEXPORT jint JNICALL Java_jdk_graal_compiler_hotspot_replaycomp_HardwarePerformanceCounters_createEventSet(JNIEnv *env, jclass cls,\n                                                                                                             jobjectArray eventNames) {\n    int eventset = PAPI_NULL;\n    int retval = PAPI_create_eventset(&eventset);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.papibridge/src/papibridge.c#L26-L62","documentation":"Error \"Failed to initialize threads for PAPI %s\n\" thrown in oracle/graal.","triggerScenarios":"Thrown at compiler/src/org.graalvm.papibridge/src/papibridge.c:44 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Failed to initialize threads for PAPI {}","solutions":["Fix the condition reported by the error: Failed to initialize threads for PAPI {}","Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call."],"exampleFix":"Validate inputs and environment so that the failing condition does not occur: Failed to initialize threads for PAPI {}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}