connectedhomeip icon indicating copy to clipboard operation
connectedhomeip copied to clipboard

Resource leak in Linux/BlueZ

Open samadDotDev opened this issue 4 years ago • 8 comments

Problem

In src/platform/Linux/bluez/MainLoop.cpp, chip::Device::Internal::MainLoop::EnsureStarted() spawns a thread which is never joined or cleaned up after.

int pthreadErr = pthread_create(&mThread, nullptr, &MainLoop::Thread, reinterpret_cast<void *>(this));

Proposed Solution

pthread_join() for mThread needs to be called at an appropriate place to wait for the thread to terminate. Since pthread_create is called with null attr, the thread is in joinable state.

samadDotDev avatar Aug 24 '21 19:08 samadDotDev

@msandstedt @z-michel

samadDotDev avatar Aug 24 '21 19:08 samadDotDev

@samadDotDev it looks like this is still an issue - can you confirm? Do you know who to assign it to?

holbrookt avatar Feb 01 '22 00:02 holbrookt

@holbrookt Yes, the latest master still has mThread in joinable state but is never joined.

samadDotDev avatar Feb 02 '22 12:02 samadDotDev

Given this is a linux platform example issue, can be resolved post v1.0

woody-apple avatar Feb 07 '22 03:02 woody-apple

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Aug 12 '22 21:08 stale[bot]

This stale issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Oct 09 '22 03:10 stale[bot]

Still an issue. But as @woody-apple, can be post-1.0.

msandstedt avatar Oct 10 '22 00:10 msandstedt

This stale issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Oct 18 '22 18:10 stale[bot]

Fixed by https://github.com/project-chip/connectedhomeip/pull/23320.

msandstedt avatar Nov 08 '22 16:11 msandstedt