Skip to content

Bug: crash when deactivating RDK services caused by Store2 listeners #6422

@npoltorapavlo

Description

@npoltorapavlo

Problem/Opportunity

When deactivating multiple services there's a crash with the following callstack, that indicates that some Store2 listener has been destroyed but not Unregistered:

Thread 5 (Thread 11409.11522 "WorkerPool::Thr"):
#0  __libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47
#1  0xb3b9e300 in __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=<optimized out>) at pthread_kill.c:43
#2  0xb3b6fbb6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0xb3b615d4 in __GI_abort () at abort.c:79
#4  0xb3d12fac in __gnu_cxx::__verbose_terminate_handler () at ../../../../../../../../work-shared/gcc-11.3.0-r0/gcc-11.3.0/libstdc++-v3/libsupc++/vterminate.cc:95
#5  0xb3d11bdc in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../../../../../work-shared/gcc-11.3.0-r0/gcc-11.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:48
#6  0xb3d11c3e in std::terminate () at ../../../../../../../../work-shared/gcc-11.3.0-r0/gcc-11.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:58
#7  0xb3d1254a in __cxxabiv1::__cxa_pure_virtual () at ../../../../../../../../work-shared/gcc-11.3.0-r0/gcc-11.3.0/libstdc++-v3/libsupc++/pure.cc:50
#8  0xac18aca6 in WPEFramework::Plugin::Sqlite::Store2::OnValueChanged (value=..., key=..., ns=..., scope=WPEFramework::Exchange::IStore2::DEVICE, this=0x181c9f0) at /usr/src/debug/rdkservices/3.0+gitAUTOINC+93fce14482-r1/git/PersistentStore/sqlite/Store2.h:639
#9  WPEFramework::Plugin::Sqlite::Store2::Job::Dispatch (this=<optimized out>) at /usr/src/debug/rdkservices/3.0+gitAUTOINC+93fce14482-r1/git/PersistentStore/sqlite/Store2.h:57
#10 0x00065c08 in WPEFramework::Core::ThreadPool::Minion::Process (this=this@entry=0x16cbdd8) at /usr/src/debug/wpeframework/4.4-r0/git/Source/core/../core/ThreadPool.h:452
#11 0x00065d66 in WPEFramework::Core::ThreadPool::Executor::Worker (this=0x16cbce8) at /usr/src/debug/wpeframework/4.4-r0/git/Source/core/../core/ThreadPool.h:540
#12 0xb3de937c in WPEFramework::Core::Thread::StartThread (cClassPointer=0x16cbce8) at /usr/src/debug/wpeframework/4.4-r0/git/Source/core/Thread.cpp:194
#13 0xb3b9cc86 in start_thread (arg=0x52a7613d) at pthread_create.c:442
#14 0xb3bed3c0 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:74 from /home/npoltorapavlo/Downloads/gdb/lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?) 

As seen, at least in UserSettings Register is used, Unregister is missing:

void UserSettingsImplementation::registerEventHandlers()
{

    if(!_registeredEventHandlers && _remotStoreObject)
    {
        _registeredEventHandlers = true;
        _remotStoreObject->Register(&_storeNotification);

Steps to reproduce

for item in "org.rdk.Bluetooth" ... "org.rdk.Network"; do
  curl -X PUT http://127.0.0.1:9998/Service/Controller/Deactivate/$item &
done 

sends multiple deactivate calls (40).

Expected Behavior

No crash

Actual Behavior

Crash

Notes (Optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions