Fix random Segmentation fault issue in CRMP testing. #5361
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Thread 8 "chip-shell" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe77fe700 (LWP 102296)]
0x00005555555781c0 in chip::System::Layer::State (this=0x0) at ../../src/system/SystemLayer.h:222
222 return this->mLayerState;
From crash log, it seems there are still pending timer alive after SecureSessionMgr is shut down.
#0 0x00005555555781c0 in chip::System::Layer::State() const (this=0x0) at ../../src/system/SystemLayer.h:222
#1 0x000055555557845c in chip::System::Layer::CancelTimer(void ()(chip::System::Layer, void*, int), void*)
(this=0x0, aOnComplete=0x55555559243e <chip::SecureSessionMgr::ExpiryTimerCallback(chip::System::Layer*, void*, int)>, aAppState=0x5555555f7ba0 <(anonymous namespace)::gSessionManager>) at ../../src/system/SystemLayer.cpp:321
#2 0x00005555555783d1 in chip::System::Layer::StartTimer(unsigned int, void ()(chip::System::Layer, void*, int), void*)
(this=0x0, aMilliseconds=5000, aComplete=0x55555559243e <chip::SecureSessionMgr::ExpiryTimerCallback(chip::System::Layer*, void*, int)>, aAppState=0x5555555f7ba0 <(anonymous namespace)::gSessionManager>)
at ../../src/system/SystemLayer.cpp:292
#3 0x0000555555591df7 in chip::SecureSessionMgr::ScheduleExpiryTimer() (this=0x5555555f7ba0 <(anonymous namespace)::gSessionManager>) at ../../src/transport/SecureSessionMgr.cpp:307
#4 0x0000555555592469 in chip::SecureSessionMgr::ExpiryTimerCallback(chip::System::Layer*, void*, int) (layer=0x5555555f87c0 chip::DeviceLayer::SystemLayer, param=0x5555555f7ba0 <(anonymous namespace)::gSessionManager>, error=0)
at ../../src/transport/SecureSessionMgr.cpp:420
#5 0x0000555555577ae7 in chip::System::Timer::HandleComplete() (this=0x5555555f8460 chip::System::Timer::sPool) at ../../src/system/SystemTimer.cpp:274
#6 0x0000555555578a5e in chip::System::Layer::HandleSelectResult(int, fd_set*, fd_set*, fd_set*)
(this=0x5555555f87c0 chip::DeviceLayer::SystemLayer, aSetSize=13, aReadSet=0x5555555f8970 chip::DeviceLayer::PlatformManagerImpl::sInstance+16, aWriteSet=0x5555555f89f0 chip::DeviceLayer::PlatformManagerImpl::sInstance+144, aExceptionSet=0x5555555f8a70 chip::DeviceLayer::PlatformManagerImpl::sInstance+272) at ../../src/system/SystemLayer.cpp:698
#7 0x0000555555582763 in chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIXchip::DeviceLayer::PlatformManagerImpl::SysProcess() (this=0x5555555f8960 chip::DeviceLayer::PlatformManagerImpl::sInstance)
at ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp:186
#8 0x000055555558230e in chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIXchip::DeviceLayer::PlatformManagerImpl::_RunEventLoop() (this=0x5555555f8960 chip::DeviceLayer::PlatformManagerImpl::sInstance)
at ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp:212
#9 0x0000555555581c8a in chip::DeviceLayer::PlatformManager::RunEventLoop() (this=0x5555555f8960 chip::DeviceLayer::PlatformManagerImpl::sInstance) at ../../src/include/platform/PlatformManager.h:204
#10 0x00005555555828b9 in chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIXchip::DeviceLayer::PlatformManagerImpl::EventLoopTaskMain(void*) (arg=0x5555555f8960 chip::DeviceLayer::PlatformManagerImpl::sInstance)
at ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.cpp:223
#11 0x00007ffff7f9c609 in start_thread (arg=) at pthread_create.c:477
#12 0x00007ffff762e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)
Summary of Changes
Clear any pending timer after SecureSessionMgr is shut down.