Blame SOURCES/0024-Do-not-report-exceptions-caught-by-native-methods.patch

b35d98
From 47461c8bd7427432bc0afe848db001e05f8d01a3 Mon Sep 17 00:00:00 2001
b35d98
From: Jakub Filak <jfilak@redhat.com>
b35d98
Date: Wed, 15 Jan 2014 11:49:36 +0100
b35d98
Subject: [PATCH 24/39] Do not report exceptions caught by native methods
b35d98
b35d98
Related to rhbz#1051198
b35d98
---
b35d98
 src/abrt-checker.c | 247 ++++++++++++++++++++++++++++++++++++++++-------------
b35d98
 src/jthread_map.c  |  26 +++---
b35d98
 src/jthread_map.h  |  18 ++--
b35d98
 3 files changed, 212 insertions(+), 79 deletions(-)
b35d98
b35d98
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
b35d98
index d5160cb..fb0c0eb 100644
b35d98
--- a/src/abrt-checker.c
b35d98
+++ b/src/abrt-checker.c
b35d98
@@ -63,9 +63,6 @@
b35d98
 /* Enables checks based on JVMTI_EVENT_VM_DEATH */
b35d98
 /* #define ABRT_VM_DEATH_CHECK */
b35d98
 
b35d98
-/* Enables checks based on JVMTI_EVENT_EXCEPTION_CATCH  */
b35d98
-/* #define ABRT_EXCEPTION_CATCH_CHECK */
b35d98
-
b35d98
 /* Enables checks based on JVMTI_EVENT_VM_OBJECT_ALLOC */
b35d98
 /* #define ABRT_OBJECT_ALLOCATION_SIZE_CHECK */
b35d98
 
b35d98
@@ -165,6 +162,19 @@ typedef struct {
b35d98
 
b35d98
 
b35d98
 /*
b35d98
+ * This structure is representation of a single report of an exception.
b35d98
+ */
b35d98
+typedef struct {
b35d98
+    char *message;
b35d98
+    char *stacktrace;
b35d98
+    char *executable;
b35d98
+    char *exception_type_name;
b35d98
+    jobject exception_object;
b35d98
+} T_exceptionReport;
b35d98
+
b35d98
+
b35d98
+
b35d98
+/*
b35d98
  * Flags for specification of destination for error reports
b35d98
  */
b35d98
 typedef enum {
b35d98
@@ -214,6 +224,9 @@ int executableFlags = 0;
b35d98
 /* Map of buffer for already reported exceptions to prevent re-reporting */
b35d98
 T_jthreadMap *threadMap;
b35d98
 
b35d98
+/* Map of uncaught exceptions. There should be only 1 per thread.*/
b35d98
+T_jthreadMap *uncaughtExceptionMap;
b35d98
+
b35d98
 
b35d98
 /* forward headers */
b35d98
 static char* get_path_to_class(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jclass class, char *class_name, const char *stringize_method_name);
b35d98
@@ -453,9 +466,12 @@ static int exception_is_intended_to_be_reported(
b35d98
 
b35d98
     if (reportedCaughExceptionTypes != NULL)
b35d98
     {
b35d98
-        *exception_type = get_exception_type_name(jvmti_env, jni_env, exception_object);
b35d98
         if (NULL == *exception_type)
b35d98
-            return 0;
b35d98
+        {
b35d98
+            *exception_type = get_exception_type_name(jvmti_env, jni_env, exception_object);
b35d98
+            if (NULL == *exception_type)
b35d98
+                return 0;
b35d98
+        }
b35d98
 
b35d98
         /* special cases for selected exceptions */
b35d98
         for (char **cursor = reportedCaughExceptionTypes; *cursor; ++cursor)
b35d98
@@ -1277,7 +1293,7 @@ static void JNICALL callback_on_thread_start(
b35d98
         return;
b35d98
     }
b35d98
 
b35d98
-    jthread_map_push(threadMap, tid, threads_exc_buf);
b35d98
+    jthread_map_push(threadMap, tid, (void *)threads_exc_buf);
b35d98
 }
b35d98
 
b35d98
 
b35d98
@@ -1304,7 +1320,25 @@ static void JNICALL callback_on_thread_end(
b35d98
         return;
b35d98
     }
b35d98
 
b35d98
-    T_jthrowableCircularBuf *threads_exc_buf = jthread_map_pop(threadMap, tid);
b35d98
+    T_exceptionReport *rpt = (T_exceptionReport *)jthread_map_pop(uncaughtExceptionMap, tid);
b35d98
+    T_jthrowableCircularBuf *threads_exc_buf = (T_jthrowableCircularBuf *)jthread_map_pop(threadMap, tid);
b35d98
+
b35d98
+    if (NULL != rpt)
b35d98
+    {
b35d98
+        if (NULL == threads_exc_buf || NULL == jthrowable_circular_buf_find(threads_exc_buf, rpt->exception_object))
b35d98
+        {
b35d98
+            report_stacktrace(NULL != rpt->executable ? rpt->executable : processProperties.main_class,
b35d98
+                              NULL != rpt->message ? rpt->message : "Uncaught exception",
b35d98
+                              rpt->stacktrace,
b35d98
+                              NULL != threads_exc_buf);
b35d98
+        }
b35d98
+
b35d98
+        free(rpt->message);
b35d98
+        free(rpt->stacktrace);
b35d98
+        free(rpt->executable);
b35d98
+        free(rpt->exception_type_name);
b35d98
+    }
b35d98
+
b35d98
     if (threads_exc_buf != NULL)
b35d98
     {
b35d98
         jthrowable_circular_buf_free(threads_exc_buf);
b35d98
@@ -2120,7 +2154,7 @@ static void JNICALL callback_on_exception(
b35d98
 
b35d98
         if (NULL != threadMap && 0 == get_tid(jni_env, thr, &tid))
b35d98
         {
b35d98
-            threads_exc_buf = jthread_map_get(threadMap, tid);
b35d98
+            threads_exc_buf = (T_jthrowableCircularBuf *)jthread_map_get(threadMap, tid);
b35d98
             VERBOSE_PRINT("Got circular buffer for thread %p\n", (void *)threads_exc_buf);
b35d98
         }
b35d98
         else
b35d98
@@ -2137,12 +2171,6 @@ static void JNICALL callback_on_exception(
b35d98
             char *class_name_ptr = NULL;
b35d98
             char *class_signature_ptr = NULL;
b35d98
 
b35d98
-            if (NULL != threads_exc_buf)
b35d98
-            {
b35d98
-                VERBOSE_PRINT("Pushing to circular buffer\n");
b35d98
-                jthrowable_circular_buf_push(threads_exc_buf, exception_object);
b35d98
-            }
b35d98
-
b35d98
             error_code = (*jvmti_env)->GetMethodName(jvmti_env, method, &method_name_ptr, &method_signature_ptr, NULL);
b35d98
             if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
                 goto callback_on_exception_cleanup;
b35d98
@@ -2176,11 +2204,47 @@ static void JNICALL callback_on_exception(
b35d98
             if (NULL == report_message)
b35d98
                 report_message = (NULL != catch_method) ? "Caught exception" : "Uncaught exception";
b35d98
 
b35d98
-            report_stacktrace(NULL != executable ? executable : processProperties.main_class,
b35d98
-                    report_message,
b35d98
-                    stack_trace_str,
b35d98
-                    NULL != threads_exc_buf);
b35d98
+            if (NULL == catch_method)
b35d98
+            {   /* Postpone reporting of uncaught exceptions as they may be caught by a native function */
b35d98
+                T_exceptionReport *rpt = malloc(sizeof(*rpt));
b35d98
+                if (NULL == rpt)
b35d98
+                {
b35d98
+                    fprintf(stderr, __FILE__ ":" STRINGIZE(__LINE__) ": malloc(): out of memory");
b35d98
+                }
b35d98
+                else
b35d98
+                {
b35d98
+                    rpt->message = message;
b35d98
+                    message = NULL;
b35d98
+
b35d98
+                    rpt->exception_type_name = exception_type_name;
b35d98
+                    exception_type_name = NULL;
b35d98
+
b35d98
+                    rpt->stacktrace = stack_trace_str;
b35d98
+                    stack_trace_str = NULL;
b35d98
+
b35d98
+                    rpt->executable = executable;
b35d98
+                    executable = NULL;
b35d98
 
b35d98
+                    rpt->exception_object = exception_object;
b35d98
+
b35d98
+                    jthread_map_push(uncaughtExceptionMap, tid, (T_exceptionReport *)rpt);
b35d98
+                }
b35d98
+            }
b35d98
+            else
b35d98
+            {
b35d98
+                report_stacktrace(NULL != executable ? executable : processProperties.main_class,
b35d98
+                        report_message,
b35d98
+                        stack_trace_str,
b35d98
+                        NULL != threads_exc_buf);
b35d98
+
b35d98
+                if (NULL != threads_exc_buf)
b35d98
+                {
b35d98
+                    VERBOSE_PRINT("Pushing to circular buffer\n");
b35d98
+                    jthrowable_circular_buf_push(threads_exc_buf, exception_object);
b35d98
+                }
b35d98
+            }
b35d98
+
b35d98
+            free(executable);
b35d98
             free(message);
b35d98
             free(stack_trace_str);
b35d98
 
b35d98
@@ -2217,18 +2281,16 @@ callback_on_exception_cleanup:
b35d98
 }
b35d98
 
b35d98
 
b35d98
-
b35d98
-#if ABRT_EXCEPTION_CATCH_CHECK
b35d98
 /*
b35d98
  * This function is called when an exception is catched.
b35d98
  */
b35d98
 static void JNICALL callback_on_exception_catch(
b35d98
             jvmtiEnv *jvmti_env,
b35d98
-            JNIEnv   *jni_env __UNUSED_VAR,
b35d98
-            jthread   thr __UNUSED_VAR,
b35d98
+            JNIEnv   *jni_env,
b35d98
+            jthread   thread,
b35d98
             jmethodID method,
b35d98
             jlocation location __UNUSED_VAR,
b35d98
-            jobject   exception __UNUSED_VAR)
b35d98
+            jobject   exception_object)
b35d98
 {
b35d98
     jvmtiError error_code;
b35d98
 
b35d98
@@ -2236,52 +2298,120 @@ static void JNICALL callback_on_exception_catch(
b35d98
     char *method_signature_ptr = NULL;
b35d98
     char *class_signature_ptr = NULL;
b35d98
 
b35d98
-    jclass class;
b35d98
-
b35d98
     /* all operations should be processed in critical section */
b35d98
     enter_critical_section(jvmti_env, shared_lock);
b35d98
 
b35d98
-    /* retrieve all required informations */
b35d98
-    error_code = (*jvmti_env)->GetMethodName(jvmti_env, method, &method_name_ptr, &method_signature_ptr, NULL);
b35d98
-    if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
-        goto callback_on_exception_catch_cleanup;
b35d98
-
b35d98
-    error_code = (*jvmti_env)->GetMethodDeclaringClass(jvmti_env, method, &class);
b35d98
-    if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
-        goto callback_on_exception_catch_cleanup;
b35d98
+    jclass class;
b35d98
 
b35d98
-    error_code = (*jvmti_env)->GetClassSignature(jvmti_env, class, &class_signature_ptr, NULL);
b35d98
-    if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
-        goto callback_on_exception_catch_cleanup;
b35d98
+    jlong tid = 0;
b35d98
 
b35d98
-#ifdef VERBOSE
b35d98
-    /* readable class name */
b35d98
-    char *class_name_ptr = format_class_name(class_signature_ptr, '.');
b35d98
-#endif
b35d98
+    if (get_tid(jni_env, thread, &tid))
b35d98
+    {
b35d98
+        fprintf(stderr, __FILE__ ":" STRINGIZE(__LINE__) ": Cannot clear uncaught exceptions");
b35d98
+        goto callback_on_exception_catch_exit;
b35d98
+    }
b35d98
 
b35d98
-    VERBOSE_PRINT("An exception was caught in a method %s%s() with signature %s\n", class_name_ptr, method_name_ptr, method_signature_ptr);
b35d98
+    T_exceptionReport *rpt = (T_exceptionReport *)jthread_map_get(uncaughtExceptionMap, tid);
b35d98
+    if (NULL == rpt)
b35d98
+    {
b35d98
+        goto callback_on_exception_catch_exit;
b35d98
+    }
b35d98
 
b35d98
-callback_on_exception_catch_cleanup:
b35d98
-    /* cleapup */
b35d98
-    if (method_name_ptr != NULL)
b35d98
+    jclass object_class = (*jni_env)->FindClass(jni_env, "java/lang/Object");
b35d98
+    if (NULL == object_class)
b35d98
     {
b35d98
-        error_code = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)method_name_ptr);
b35d98
-        check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__));
b35d98
+        VERBOSE_PRINT("Cannot find java/lang/Object class");
b35d98
+        goto callback_on_exception_catch_exit;
b35d98
     }
b35d98
-    if (method_signature_ptr != NULL)
b35d98
+
b35d98
+    jmethodID equal_method = (*jni_env)->GetMethodID(jni_env, object_class, "equals", "(Ljava/lang/Object;)Z");
b35d98
+    if (NULL == equal_method)
b35d98
     {
b35d98
-        error_code = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)method_signature_ptr);
b35d98
-        check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__));
b35d98
+        VERBOSE_PRINT("Cannot find java.lang.Object.equals(Ljava/lang/Object;)Z method");
b35d98
+        (*jni_env)->DeleteLocalRef(jni_env, object_class);
b35d98
+        goto callback_on_exception_catch_exit;
b35d98
     }
b35d98
-    if (class_signature_ptr != NULL)
b35d98
+
b35d98
+    jboolean equal_objects = (*jni_env)->CallBooleanMethod(jni_env, exception_object, equal_method, rpt->exception_object);
b35d98
+    if (!equal_objects)
b35d98
+        goto callback_on_exception_catch_exit;
b35d98
+
b35d98
+    /* Faster than get()-pop() approach is faster because it is search-and-search-free but
b35d98
+     * pop()-push() approach is search-free-and-search-malloc
b35d98
+     *
b35d98
+     * JVM always catches java.security.PrivilegedActionException while
b35d98
+     * handling uncaught java.lang.ClassNotFoundException throw by
b35d98
+     * initialization of the system (native) class loader.
b35d98
+     */
b35d98
+    jthread_map_pop(uncaughtExceptionMap, tid);
b35d98
+
b35d98
+    if (exception_is_intended_to_be_reported(jvmti_env, jni_env, rpt->exception_object, &(rpt->exception_type_name)))
b35d98
     {
b35d98
-        error_code = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)class_signature_ptr);
b35d98
-        check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__));
b35d98
+        jlong tid = 0;
b35d98
+        T_jthrowableCircularBuf *threads_exc_buf = NULL;
b35d98
+
b35d98
+        if (NULL != threadMap && 0 == get_tid(jni_env, thread, &tid))
b35d98
+        {
b35d98
+            threads_exc_buf = (T_jthrowableCircularBuf *)jthread_map_get(threadMap, tid);
b35d98
+            VERBOSE_PRINT("Got circular buffer for thread %p\n", (void *)threads_exc_buf);
b35d98
+        }
b35d98
+        else
b35d98
+        {
b35d98
+            VERBOSE_PRINT("Cannot get thread's ID. Disabling reporting to ABRT.");
b35d98
+        }
b35d98
+
b35d98
+        if (NULL == threads_exc_buf || NULL == jthrowable_circular_buf_find(threads_exc_buf, rpt->exception_object))
b35d98
+        {
b35d98
+            /* retrieve all required informations */
b35d98
+            error_code = (*jvmti_env)->GetMethodName(jvmti_env, method, &method_name_ptr, &method_signature_ptr, NULL);
b35d98
+            if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
+                goto callback_on_exception_catch_cleanup;
b35d98
+
b35d98
+            error_code = (*jvmti_env)->GetMethodDeclaringClass(jvmti_env, method, &class);
b35d98
+            if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
+                goto callback_on_exception_catch_cleanup;
b35d98
+
b35d98
+            error_code = (*jvmti_env)->GetClassSignature(jvmti_env, class, &class_signature_ptr, NULL);
b35d98
+            if (check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__)))
b35d98
+                goto callback_on_exception_catch_cleanup;
b35d98
+
b35d98
+            /* readable class name */
b35d98
+            char *class_name_ptr = format_class_name(class_signature_ptr, '\0');
b35d98
+            char *message = format_exception_reason_message(/*caught*/1, rpt->exception_type_name,  class_name_ptr, method_name_ptr);
b35d98
+            report_stacktrace(NULL != rpt->executable ? rpt->executable : processProperties.main_class,
b35d98
+                              NULL != message ? message : "Caught exception",
b35d98
+                              rpt->stacktrace,
b35d98
+                              NULL != threads_exc_buf);
b35d98
+
b35d98
+            if (NULL != threads_exc_buf)
b35d98
+            {
b35d98
+                VERBOSE_PRINT("Pushing to circular buffer\n");
b35d98
+                jthrowable_circular_buf_push(threads_exc_buf, rpt->exception_object);
b35d98
+            }
b35d98
+
b35d98
+callback_on_exception_catch_cleanup:
b35d98
+            /* cleapup */
b35d98
+            if (method_name_ptr != NULL)
b35d98
+            {
b35d98
+                error_code = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)method_name_ptr);
b35d98
+                check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__));
b35d98
+            }
b35d98
+            if (class_signature_ptr != NULL)
b35d98
+            {
b35d98
+                error_code = (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *)class_signature_ptr);
b35d98
+                check_jvmti_error(jvmti_env, error_code, __FILE__ ":" STRINGIZE(__LINE__));
b35d98
+            }
b35d98
+        }
b35d98
     }
b35d98
 
b35d98
+    free(rpt->message);
b35d98
+    free(rpt->stacktrace);
b35d98
+    free(rpt->executable);
b35d98
+    free(rpt->exception_type_name);
b35d98
+
b35d98
+callback_on_exception_catch_exit:
b35d98
     exit_critical_section(jvmti_env, shared_lock);
b35d98
 }
b35d98
-#endif /* ABRT_EXCEPTION_CATCH_CHECK */
b35d98
 
b35d98
 
b35d98
 
b35d98
@@ -2497,10 +2627,8 @@ jvmtiError register_all_callback_functions(jvmtiEnv *jvmti_env)
b35d98
     /* JVMTI_EVENT_EXCEPTION */
b35d98
     callbacks.Exception = &callback_on_exception;
b35d98
 
b35d98
-#if ABRT_EXCEPTION_CATCH_CHECK
b35d98
     /* JVMTI_EVENT_EXCEPTION_CATCH */
b35d98
     callbacks.ExceptionCatch = &callback_on_exception_catch;
b35d98
-#endif /* ABRT_EXCEPTION_CATCH_CHECK */
b35d98
 
b35d98
 #if ABRT_OBJECT_ALLOCATION_SIZE_CHECK
b35d98
     /* JVMTI_EVENT_VM_OBJECT_ALLOC */
b35d98
@@ -2580,12 +2708,10 @@ jvmtiError set_event_notification_modes(jvmtiEnv* jvmti_env)
b35d98
         return error_code;
b35d98
     }
b35d98
 
b35d98
-#if ABRT_EXCEPTION_CATCH_CHECK
b35d98
     if ((error_code = set_event_notification_mode(jvmti_env, JVMTI_EVENT_EXCEPTION_CATCH)) != JNI_OK)
b35d98
     {
b35d98
         return error_code;
b35d98
     }
b35d98
-#endif /* ABRT_EXCEPTION_CATCH_CHECK */
b35d98
 
b35d98
 #if ABRT_OBJECT_ALLOCATION_SIZE_CHECK
b35d98
     if ((error_code = set_event_notification_mode(jvmti_env, JVMTI_EVENT_VM_OBJECT_ALLOC)) != JNI_OK)
b35d98
@@ -2903,6 +3029,12 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
b35d98
         return -1;
b35d98
     }
b35d98
 
b35d98
+    uncaughtExceptionMap = jthread_map_new();
b35d98
+    if (NULL == uncaughtExceptionMap)
b35d98
+    {
b35d98
+        fprintf(stderr, __FILE__ ":" STRINGIZE(__LINE__) ": can not create a set of uncaught exceptions\n");
b35d98
+        return -1;
b35d98
+    }
b35d98
     return JNI_OK;
b35d98
 }
b35d98
 
b35d98
@@ -2928,6 +3060,7 @@ JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm __UNUSED_VAR)
b35d98
         fclose(fout);
b35d98
     }
b35d98
 
b35d98
+    jthread_map_free(uncaughtExceptionMap);
b35d98
     jthread_map_free(threadMap);
b35d98
 }
b35d98
 
b35d98
diff --git a/src/jthread_map.c b/src/jthread_map.c
b35d98
index 29c5c29..cd5ca52 100644
b35d98
--- a/src/jthread_map.c
b35d98
+++ b/src/jthread_map.c
b35d98
@@ -35,7 +35,7 @@ struct jthread_map_item;
b35d98
 
b35d98
 typedef struct jthread_map_item {
b35d98
     long tid;                         ///< item ID from Thread.getId()
b35d98
-    T_jthrowableCircularBuf *buffer;  ///< an instance of circular buffer for thread
b35d98
+    void *data;                       ///< data
b35d98
     struct jthread_map_item *next;    ///< a next item mapped to same element
b35d98
 } T_jthreadMapItem;
b35d98
 
b35d98
@@ -76,7 +76,7 @@ void jthread_map_free(T_jthreadMap *map)
b35d98
 
b35d98
 
b35d98
 
b35d98
-static T_jthreadMapItem *jthrowable_map_item_new(long tid, T_jthrowableCircularBuf *buffer)
b35d98
+static T_jthreadMapItem *jthrowable_map_item_new(long tid, void *item)
b35d98
 {
b35d98
     T_jthreadMapItem *itm = malloc(sizeof(*itm));
b35d98
     if (NULL == itm)
b35d98
@@ -86,7 +86,7 @@ static T_jthreadMapItem *jthrowable_map_item_new(long tid, T_jthrowableCircularB
b35d98
     }
b35d98
 
b35d98
     itm->tid = tid;
b35d98
-    itm->buffer = buffer;
b35d98
+    itm->data = item;
b35d98
     itm->next = NULL;
b35d98
     return itm;
b35d98
 }
b35d98
@@ -105,7 +105,7 @@ static void jthread_map_item_free(T_jthreadMapItem *itm)
b35d98
 
b35d98
 
b35d98
 
b35d98
-void jthread_map_push(T_jthreadMap *map, jlong tid, T_jthrowableCircularBuf *buffer)
b35d98
+void jthread_map_push(T_jthreadMap *map, jlong tid, void *item)
b35d98
 {
b35d98
     assert(NULL != map);
b35d98
 
b35d98
@@ -122,7 +122,7 @@ void jthread_map_push(T_jthreadMap *map, jlong tid, T_jthrowableCircularBuf *buf
b35d98
 
b35d98
     if (NULL == itm)
b35d98
     {
b35d98
-        T_jthreadMapItem *new = jthrowable_map_item_new(tid, buffer);
b35d98
+        T_jthreadMapItem *new = jthrowable_map_item_new(tid, item);
b35d98
         if (last == NULL)
b35d98
         {
b35d98
             map->items[index] = new;
b35d98
@@ -138,39 +138,39 @@ void jthread_map_push(T_jthreadMap *map, jlong tid, T_jthrowableCircularBuf *buf
b35d98
 
b35d98
 
b35d98
 
b35d98
-T_jthrowableCircularBuf *jthread_map_get(T_jthreadMap *map, jlong tid)
b35d98
+void *jthread_map_get(T_jthreadMap *map, jlong tid)
b35d98
 {
b35d98
     assert(NULL != map);
b35d98
 
b35d98
     pthread_mutex_lock(&map->mutex);
b35d98
 
b35d98
     const size_t index = tid % MAP_SIZE;
b35d98
-    T_jthrowableCircularBuf *buffer = NULL;
b35d98
+    void *data = NULL;
b35d98
 
b35d98
     for (T_jthreadMapItem *itm = map->items[index]; NULL != itm; itm = itm->next)
b35d98
     {
b35d98
         if (itm->tid == tid)
b35d98
         {
b35d98
-            buffer = itm->buffer;
b35d98
+            data = itm->data;
b35d98
             break;
b35d98
         }
b35d98
     }
b35d98
 
b35d98
     pthread_mutex_unlock(&map->mutex);
b35d98
 
b35d98
-    return buffer;
b35d98
+    return data;
b35d98
 }
b35d98
 
b35d98
 
b35d98
 
b35d98
-T_jthrowableCircularBuf *jthread_map_pop(T_jthreadMap *map, jlong tid)
b35d98
+void *jthread_map_pop(T_jthreadMap *map, jlong tid)
b35d98
 {
b35d98
     assert(NULL != map);
b35d98
 
b35d98
     pthread_mutex_lock(&map->mutex);
b35d98
 
b35d98
     const size_t index = tid % MAP_SIZE;
b35d98
-    T_jthrowableCircularBuf *buffer = NULL;
b35d98
+    void *data = NULL;
b35d98
     if (NULL != map->items[index])
b35d98
     {
b35d98
         T_jthreadMapItem *last = NULL;
b35d98
@@ -183,7 +183,7 @@ T_jthrowableCircularBuf *jthread_map_pop(T_jthreadMap *map, jlong tid)
b35d98
 
b35d98
         if (NULL != itm)
b35d98
         {
b35d98
-            buffer = itm->buffer;
b35d98
+            data = itm->data;
b35d98
 
b35d98
             if (NULL == last)
b35d98
             {
b35d98
@@ -200,7 +200,7 @@ T_jthrowableCircularBuf *jthread_map_pop(T_jthreadMap *map, jlong tid)
b35d98
 
b35d98
     pthread_mutex_unlock(&map->mutex);
b35d98
 
b35d98
-    return buffer;
b35d98
+    return data;
b35d98
 }
b35d98
 
b35d98
 
b35d98
diff --git a/src/jthread_map.h b/src/jthread_map.h
b35d98
index 29fcc92..52d2832 100644
b35d98
--- a/src/jthread_map.h
b35d98
+++ b/src/jthread_map.h
b35d98
@@ -23,7 +23,7 @@
b35d98
 
b35d98
 
b35d98
 /*
b35d98
- * Map of TID to jthrowable_circular_buf
b35d98
+ * Map of TID to (void *)
b35d98
  */
b35d98
 typedef struct jthread_map T_jthreadMap;
b35d98
 
b35d98
@@ -41,7 +41,7 @@ T_jthreadMap *jthread_map_new();
b35d98
 /*
b35d98
  * Frees map's memory
b35d98
  *
b35d98
- * Doesn't release memory of stored circular buffers.
b35d98
+ * Doesn't release memory of stored (void *).
b35d98
  *
b35d98
  * @param map Pointer to @jthread_map. Accepts NULL
b35d98
  */
b35d98
@@ -50,15 +50,15 @@ void jthread_map_free(T_jthreadMap *map);
b35d98
 
b35d98
 
b35d98
 /*
b35d98
- * Adds a new map item identified by @tid with value @buffer
b35d98
+ * Adds a new map item identified by @tid with value @item
b35d98
  *
b35d98
  * Does nothing if item with same @tid already exists in @map
b35d98
  *
b35d98
  * @param map Map
b35d98
  * @param tid New item ID
b35d98
- * @param buffer A pointer to @jthrowable_circular_buf
b35d98
+ * @param item A (void *) item
b35d98
  */
b35d98
-void jthread_map_push(T_jthreadMap *map, jlong tid, T_jthrowableCircularBuf *buffer);
b35d98
+void jthread_map_push(T_jthreadMap *map, jlong tid, void *item);
b35d98
 
b35d98
 
b35d98
 
b35d98
@@ -67,9 +67,9 @@ void jthread_map_push(T_jthreadMap *map, jlong tid, T_jthrowableCircularBuf *buf
b35d98
  *
b35d98
  * @param map Map
b35d98
  * @param tid Required ID
b35d98
- * @returns A pointer to stored @jthrowable_circular_buf or NULL if item with @tid was not found
b35d98
+ * @returns A stored item or NULL if item with @tid was not found
b35d98
  */
b35d98
-T_jthrowableCircularBuf *jthread_map_get(T_jthreadMap *map, jlong tid);
b35d98
+void *jthread_map_get(T_jthreadMap *map, jlong tid);
b35d98
 
b35d98
 
b35d98
 
b35d98
@@ -78,9 +78,9 @@ T_jthrowableCircularBuf *jthread_map_get(T_jthreadMap *map, jlong tid);
b35d98
  *
b35d98
  * @param map Map
b35d98
  * @param tid Removed item's ID
b35d98
- * @returns A pointer to stored @jthrowable_circular_buf or NULL if item with @tid was not found
b35d98
+ * @returns A stored item or NULL if item with @tid was not found
b35d98
  */
b35d98
-T_jthrowableCircularBuf *jthread_map_pop(T_jthreadMap *map, jlong tid);
b35d98
+void *jthread_map_pop(T_jthreadMap *map, jlong tid);
b35d98
 
b35d98
 
b35d98
 
b35d98
-- 
b35d98
1.8.3.1
b35d98