Now I get an assert from line 4167 in ‘tasks.c’ function xTaskPriorityDisinherit() [V10.4.3] which is line ‘configASSERT( pxTCB == pxCurrentTCB )’. I’d say it now crashes one time out of four attempts with the same assert. The other times the test case is run successfully.
The assert is triggered by my CicMutex class, which is a standard mutex wrapper class. It is declared at the top of CicSettings::config() and destructed (and mutex is released) when the object is out of scope. Actually this type of crash smells stack overwrite, but I’ve tested to increase task stack size with no difference. All other threads/tasks seems to sleep nicely from looking at the crash printout. I tested to remove the mutex for this scope, but it failed on another mutex release with same assert. I suspect it’s my code causing the crash, but it’s weird that it often runs fine.
From test run:
[----------] 2 tests from CicFreqManagerTest [ RUN ] CicFreqManagerTest.SetGetFrequency [cic_freq_mgr_test.cpp:99] Settings file: 'cic_freq_mgr_settings.txt' [cic_settings.cpp:250] CIC Settings read 8064 [B] from NVM in 0 [ms]. ASSERT-os/FreeRTOS/tasks.c-4167 Aborted (core dumped)
c From core dump:Reading symbols from CIC_GTEST.exe... [New LWP 5444] [New LWP 5445] [New LWP 5447] [New LWP 5443] [New LWP 5446] [New LWP 5442] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./CIC_GTEST.exe'. Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. [Current thread is 1 (Thread 0x7f97f4a2e700 (LWP 5444))] (gdb) thread apply all bt Thread 6 (Thread 0x7f97f5230740 (LWP 5442)): #0 futex_wait_cancelable (private=, expected=0, futex_word=0x7f97f0003494) at ../sysdeps/nptl/futex-internal.h:183 #1 __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f97f0003440, cond=0x7f97f0003468) at pthread_cond_wait.c:508 #2 __pthread_cond_wait (cond=0x7f97f0003468, mutex=0x7f97f0003440) at pthread_cond_wait.c:638 #3 0x000055dc2e38d7d7 in event_wait (ev=0x7f97f0003440) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c:41 #4 0x000055dc2e38d4e9 in prvSuspendSelf (thread=0x7f97f0003338) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:496 #5 0x000055dc2e38d4bd in prvSwitchThread (pxThreadToResume=0x7f97e800e2b8, pxThreadToSuspend=0x7f97f0003338) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:474 #6 0x000055dc2e38d36f in vPortSystemTickHandler (sig=14) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:400 #7 #8 0x00007f97f57f73bf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=req@entry=0x7fff343e38f0, rem=rem@entry=0x7fff343e38f0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 #9 0x00007f97f57fd047 in __GI___nanosleep (requested_time=requested_time@entry=0x7fff343e38f0, remaining=remaining@entry=0x7fff343e38f0) at nanosleep.c:27 #10 0x00007f97f57fcf7e in __sleep (seconds=0) at ../sysdeps/posix/sleep.c:55 #11 0x000055dc2e3fe359 in main (argc=1, argv=0x7fff343e3a38) at gtest/main_gtest.cpp:72 Thread 5 (Thread 0x7f97ef7fe700 (LWP 5446)): #0 futex_wait_cancelable (private=, expected=0, futex_word=0x7f97f0005190) at ../sysdeps/nptl/futex-internal.h:183 #1 __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f97f0005140, cond=0x7f97f0005168) at pthread_cond_wait.c:508 #2 __pthread_cond_wait (cond=0x7f97f0005168, mutex=0x7f97f0005140) at pthread_cond_wait.c:638 #3 0x000055dc2e38d7d7 in event_wait (ev=0x7f97f0005140) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c:41 #4 0x000055dc2e38d4e9 in prvSuspendSelf (thread=0x7f97f0005038) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:496 #5 0x000055dc2e38d4bd in prvSwitchThread (pxThreadToResume=0x7f97f0003338, pxThreadToSuspend=0x7f97f0005038) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:474 #6 0x000055dc2e38d181 in vPortYieldFromISR () at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:279 #7 0x000055dc2e38d196 in vPortYield () at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:287 #8 0x000055dc2e38c918 in prvProcessTimerOrBlockTask (xNextExpireTime=0, xListWasEmpty=1) at os/FreeRTOS/timers.c:633 #9 0x000055dc2e38c86d in prvTimerTask (pvParameters=0x0) at os/FreeRTOS/timers.c:579 #10 0x000055dc2e38d451 in prvWaitForStart (pvParams=0x7f97f0005038) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:440 #11 0x00007f97f5355609 in start_thread (arg=) at pthread_create.c:477 #12 0x00007f97f5839293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 4 (Thread 0x7f97f522f700 (LWP 5443)): #0 0x00007f97f575e322 in __GI___sigtimedwait (set=set@entry=0x7f97f522ee20, info=info@entry=0x7f97f522ed60, timeout=timeout@entry=0x0) at ../sysdeps/unix/sysv/linux/sigtimedwait.c:29 #1 0x00007f97f575d6ac in __GI___sigwait (set=0x7f97f522ee20, sig=0x7f97f522ee1c) at ../sysdeps/unix/sysv/linux/sigwait.c:28 #2 0x000055dc2e38d094 in xPortStartScheduler () at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:197 #3 0x000055dc2e38a688 in vTaskStartScheduler () at os/FreeRTOS/tasks.c:2089 #4 0x000055dc2e3fe2cc in free_rtos_thread (data=0x0) at gtest/main_gtest.cpp:50 #5 0x00007f97f5355609 in start_thread (arg=) at pthread_create.c:477 #6 0x00007f97f5839293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 3 (Thread 0x7f97eeffd700 (LWP 5447)): #0 futex_wait_cancelable (private=, expected=0, futex_word=0x7f97e8002630) at ../sysdeps/nptl/futex-internal.h:183 #1 __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f97e80025e0, cond=0x7f97e8002608) at pthread_cond_wait.c:508 #2 __pthread_cond_wait (cond=0x7f97e8002608, mutex=0x7f97e80025e0) at pthread_cond_wait.c:638 #3 0x000055dc2e38d7d7 in event_wait (ev=0x7f97e80025e0) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c:41 #4 0x000055dc2e38d4e9 in prvSuspendSelf (thread=0x7f97e800e2b8) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:496 #5 0x000055dc2e38d42d in prvWaitForStart (pvParams=0x7f97e800e2b8) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:433 #6 0x00007f97f5355609 in start_thread (arg=) at pthread_create.c:477 #7 0x00007f97f5839293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 2 (Thread 0x7f97effff700 (LWP 5445)): #0 futex_wait_cancelable (private=, expected=0, futex_word=0x7f97f0003f10) at ../sysdeps/nptl/futex-internal.h:183 #1 __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f97f0003ec0, cond=0x7f97f0003ee8) at pthread_cond_wait.c:508 #2 __pthread_cond_wait (cond=0x7f97f0003ee8, mutex=0x7f97f0003ec0) at pthread_cond_wait.c:638 #3 0x000055dc2e38d7d7 in event_wait (ev=0x7f97f0003ec0) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c:41 #4 0x000055dc2e38d4e9 in prvSuspendSelf (thread=0x7f97f0003db8) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:496 #5 0x000055dc2e38d42d in prvWaitForStart (pvParams=0x7f97f0003db8) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:433 #6 0x00007f97f5355609 in start_thread (arg=) at pthread_create.c:477 #7 0x00007f97f5839293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 --Type for more, q to quit, c to continue without paging--c Thread 1 (Thread 0x7f97f4a2e700 (LWP 5444)): #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007f97f573c859 in __GI_abort () at abort.c:79 #2 0x000055dc2e38e895 in cic_assert_failed (file=0x55dc2e450018 "os/FreeRTOS/tasks.c", line=4167) at gtest/ports/src/cic_common_port.c:29 #3 0x000055dc2e38b7d7 in xTaskPriorityDisinherit (pxMutexHolder=0x7f97f0003370) at os/FreeRTOS/tasks.c:4167 #4 0x000055dc2e38975d in prvCopyDataToQueue (pxQueue=0x7f97e800ce50, pvItemToQueue=0x0, xPosition=0) at os/FreeRTOS/queue.c:2144 #5 0x000055dc2e388f06 in xQueueGenericSend (xQueue=0x7f97e800ce50, pvItemToQueue=0x0, xTicksToWait=0, xCopyPosition=0) at os/FreeRTOS/queue.c:866 #6 0x000055dc2e39217c in CicMutex::~CicMutex (this=0x7f97f4a2db40, __in_chrg=) at cic/inc/cic_mutex.hpp:42 #7 0x000055dc2e3bd4a1 in CicSettings::config (this=0x7f97e800c670) at cic/src/cic_settings.cpp:187 #8 0x000055dc2e3fe0cc in CicSettingsMock::config (this=0x7f97e800c670, settings_file_name_p=0x55dc2e46c09b "cic_freq_mgr_settings.txt") at gtest/mocks/src/cic_settings_mock.cpp:45 #9 0x000055dc2e41e1c1 in CicFreqManagerTest::SetUp (this=0x7f97e800a530) at gtest/tests/src/cic_freq_mgr_test.cpp:100 #10 0x000055dc2e44edd1 in testing::internal::HandleSehExceptionsInMethodIfSupported (location=0x55dc2e46d997 "SetUp()", method=, object=0x7f97e800a530) at ./googletest/src/gtest.cc:2414 #11 testing::internal::HandleExceptionsInMethodIfSupported (object=object@entry=0x7f97e800a530, method=, location=location@entry=0x55dc2e46d997 "SetUp()") at ./googletest/src/gtest.cc:2469 #12 0x000055dc2e442c11 in testing::Test::Run (this=0x7f97e800a530) at ./googletest/src/gtest.cc:2503 #13 testing::Test::Run (this=0x7f97e800a530) at ./googletest/src/gtest.cc:2498 #14 0x000055dc2e442de5 in testing::TestInfo::Run (this=0x55dc2eff91b0) at ./googletest/src/gtest.cc:2684 #15 testing::TestInfo::Run (this=0x55dc2eff91b0) at ./googletest/src/gtest.cc:2657 #16 0x000055dc2e442ecd in testing::TestSuite::Run (this=0x55dc2eff9380) at ./googletest/src/gtest.cc:2816 #17 testing::TestSuite::Run (this=0x55dc2eff9380) at ./googletest/src/gtest.cc:2795 #18 0x000055dc2e4433ec in testing::internal::UnitTestImpl::RunAllTests (this=0x55dc2eff40a0) at /usr/include/c++/9/bits/stl_vector.h:1040 #19 0x000055dc2e44f341 in testing::internal::HandleSehExceptionsInMethodIfSupported (location=0x55dc2e46edf8 "auxiliary test code (environments or event listeners)", method=, object=0x55dc2eff40a0) at ./googletest/src/gtest.cc:2414 #20 testing::internal::HandleExceptionsInMethodIfSupported (object=0x55dc2eff40a0, method=, location=location@entry=0x55dc2e46edf8 "auxiliary test code (environments or event listeners)") at ./googletest/src/gtest.cc:2469 #21 0x000055dc2e44361c in testing::UnitTest::Run (this=0x55dc2e4c8980 ) at ./googletest/include/gtest/gtest.h:1412 #22 0x000055dc2e3fe200 in RUN_ALL_TESTS () at /usr/include/gtest/gtest.h:2490 #23 0x000055dc2e3fe217 in gtest_task (param=0x0) at gtest/main_gtest.cpp:19 #24 0x000055dc2e38d451 in prvWaitForStart (pvParams=0x7f97f0003338) at os/FreeRTOS/portable/ThirdParty/GCC/Posix/port.c:440 #25 0x00007f97f5355609 in start_thread (arg=) at pthread_create.c:477 #26 0x00007f97f5839293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95