Copilot commented on code in PR #802:
URL: https://github.com/apache/celix/pull/802#discussion_r2389635709
##########
libs/framework/src/service_tracker.c:
##########
@@ -555,6 +542,12 @@ static celix_status_t
serviceTracker_untrack(service_tracker_t* tracker, service
static void serviceTracker_untrackTracked(service_tracker_t *tracker,
celix_tracked_entry_t *tracked, int trackedSize, bool set) {
assert(tracker != NULL);
+ celixThreadMutex_lock(&tracked->mutex);
+ while (tracked->useCount > 1) {
+ celixThreadCondition_wait(&tracked->useCond, &tracked->mutex);
+ }
Review Comment:
The condition should check `tracked->useCount != 0` instead of `> 1`. The
current logic may cause premature cleanup when useCount is exactly 1,
potentially leading to race conditions or use-after-free issues.
##########
bundles/remote_services/remote_service_admin_shm_v2/shm_pool/src/shm_cache.c:
##########
@@ -138,7 +138,7 @@ static void shmCache_destroyBlock(shm_cache_t *shmCache,
shm_cache_block_t *shmB
void * shmCache_getMemoryPtr(shm_cache_t *shmCache, int shmId, ssize_t
memoryOffset) {
void *ptr = NULL;
- if (shmCache != NULL && shmId > 0 && memoryOffset > 0) {
+ if (shmCache != NULL && shmId >= 0 && memoryOffset > 0) {
Review Comment:
The condition allows `shmId == 0` which may be a valid shared memory
identifier. The comment in the PR description mentions fixing 'RPC
communication failure when the shared memory id is 0', but this change assumes
0 is always invalid. Verify that 0 is indeed an invalid shared memory ID on all
target platforms.
```suggestion
if (shmCache != NULL && shmId >= 0 && memoryOffset >= 0) {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]