Skip to content

Commit

Permalink
[clang-support] Define __SANITIZE_ADDRESS__ if ASAN is enabled (#15138)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 1, 2023
1 parent abf858b commit d9670a5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/credentials/GroupDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,8 @@ void GroupDataProviderImpl::Finish()
mGroupKeyIterators.ReleaseAll();
mEndpointIterators.ReleaseAll();
mKeySetIterators.ReleaseAll();
mGroupSessionsIterator.ReleaseAll();
mKeyContexPool.ReleaseAll();
}

//
Expand Down
9 changes: 9 additions & 0 deletions src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,16 @@ static void OnLwIPInitComplete(void * arg)

void ShutdownNetwork()
{
gTCP.ForEachEndPoint([](TCPEndPoint * lEndPoint) -> Loop {
gTCP.ReleaseEndPoint(lEndPoint);
return Loop::Continue;
});
gTCP.Shutdown();

gUDP.ForEachEndPoint([](UDPEndPoint * lEndPoint) -> Loop {
gUDP.ReleaseEndPoint(lEndPoint);
return Loop::Continue;
});
gUDP.Shutdown();
#if CHIP_SYSTEM_CONFIG_USE_LWIP
ReleaseLwIP();
Expand Down
7 changes: 7 additions & 0 deletions src/lib/support/Pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ class HeapObjectPool : public internal::Statistics, public internal::PoolCommon<
HeapObjectPool() {}
~HeapObjectPool()
{
#ifndef __SANITIZE_ADDRESS__
#ifdef __clang__
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__ 1
#endif
#endif
#endif
#if __SANITIZE_ADDRESS__
// Free all remaining objects so that ASAN can catch specific use-after-free cases.
ReleaseAll();
Expand Down
3 changes: 1 addition & 2 deletions src/system/SystemLayerImplSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ CHIP_ERROR LayerImplSelect::Shutdown()
dispatch_source_cancel(timer->mTimerSource);
dispatch_release(timer->mTimerSource);
}

mTimerPool.Release(timer);
}
mTimerPool.ReleaseAll();
#else // CHIP_SYSTEM_CONFIG_USE_DISPATCH
mTimerList.Clear();
mTimerPool.ReleaseAll();
Expand Down
2 changes: 1 addition & 1 deletion src/transport/raw/tests/NetworkTestHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CHIP_ERROR IOContext::Shutdown()
CHIP_ERROR err = CHIP_NO_ERROR;

ShutdownNetwork();
gSystemLayer.Shutdown();
ShutdownSystemLayer();
Platform::MemoryShutdown();

return err;
Expand Down

0 comments on commit d9670a5

Please sign in to comment.