-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Problem:
The current code always calls munmap() when freeing shared memory in DataPlaneInSharedMemory::UnmapBuffers, regardless of the actual shared memory backend. However, munmap() is only correct for POSIX shared memory (mmap()), not for System V (shmat()).
When compiled without YANET_USE_POSIX_SHARED_MEMORY, shmget()/shmat() is used, so shmdt() must be called to detach the segment. Otherwise, munmap() fails with EINVAL (22) and memory cleanup is broken.
Example Log Output:
[ERROR] Error munmap 22: Invalid argument
Impact
- noisy error messages on every restart/shutdown
- shared-memory segment is not detached → kernel IPC table slowly fills
- potential memory-leak symptoms in long-running environments
Possible fix
(common/sdpcommon.h)
void UnmapBuffers(uint64_t size) {
if (!dataplane_data) return;
#ifdef YANET_USE_POSIX_SHARED_MEMORY
if (munmap(dataplane_data, size) < 0) {
YANET_LOG_ERROR("Error munmap %d: %s", errno, strerror(errno));
}
#else
if (shmdt(dataplane_data) < 0) {
YANET_LOG_ERROR("Error shmdt %d: %s", errno, strerror(errno));
}
#endif
dataplane_data = nullptr;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels