PengZheng commented on code in PR #683:
URL: https://github.com/apache/celix/pull/683#discussion_r1381421352


##########
libs/framework/src/framework.c:
##########
@@ -2531,21 +2531,22 @@ long celix_framework_scheduleEvent(celix_framework_t* 
fw,
         return -1L; //error logged by celix_scheduledEvent_create
     }
 
+    long id = celix_scheduledEvent_getId(event);
     fw_log(fw->logger,
            CELIX_LOG_LEVEL_DEBUG,
            "Added scheduled event '%s' (id=%li) for bundle '%s' (id=%li).",
            celix_scheduledEvent_getName(event),
-           celix_scheduledEvent_getId(event),
+           id,
            celix_bundle_getSymbolicName(bndEntry->bnd),
            bndId);
     celix_framework_bundleEntry_decreaseUseCount(bndEntry);
 
     celixThreadMutex_lock(&fw->dispatcher.mutex);
-    celix_longHashMap_put(fw->dispatcher.scheduledEvents, 
celix_scheduledEvent_getId(event), event);
+    celix_longHashMap_put(fw->dispatcher.scheduledEvents, id, event);
     celixThreadCondition_broadcast(&fw->dispatcher.cond); //notify dispatcher 
thread for newly added scheduled event
     celixThreadMutex_unlock(&fw->dispatcher.mutex);
 
-    return celix_scheduledEvent_getId(event);
+    return id;

Review Comment:
   Accessing event id without lock protection leads to use-after-free. 
   I just ignored this last line when this was first encountered.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to