alxhoff / FreeRTOS-Emulator

POSIX based FreeRTOS emulator with SDL2 graphics interface and multiple async communications interfaces, aiming to make it possible to teach FreeRTOS without embedded hardware using similar processes
https://alxhoff.github.io/FreeRTOS-Emulator/
GNU General Public License v3.0
60 stars 105 forks source link

Thread safe means of printing to standard streams added to allow for … #47

Closed alxhoff closed 4 years ago

alxhoff commented 4 years ago

…wild amounts of printing, #21

Is a bit hacky, was done quickly. Hopefully a stable drop in wrapper.

PhilippvK commented 4 years ago

I unfortunately have to say that your code freezes my emulator after a few seconds (docker toolchain)

Will test inside virtualbox now.

PhilippvK commented 4 years ago

Also broken in virtualbox and vmware...

PhilippvK commented 4 years ago

If we can not figure out whats wrong, we should stick with the unsafe printf...

I can add a section about debugging methods to the wiki, mentioning that debugging via GDB or printing text via the drawing api is recommended, usage of printf only okay for error messages and single temporary debugging statements inside single tasks.

alxhoff commented 4 years ago

Can you give me a backtrace of the fault from GDB? I might try developing in the VM tomorrow and see if I can get the error to be thrown.

PhilippvK commented 4 years ago

I will have a rest before... At this point I can only say, that the program does not respond to any inputs, even ctrl+c did nothing so I ran killall to quit it. Have you tested the api with the AsyncIO printouts enabled?

PhilippvK commented 4 years ago

I assume that my backtrace does not contain the relevant parts but let me know what you need exactly.

Initializing: Running as PID: 207
[New Thread 0x7ffff0b87700 (LWP 211)]
[New Thread 0x7ffff0386700 (LWP 212)]
[New Thread 0x7fffed85c700 (LWP 214)]
[New Thread 0x7fffed05b700 (LWP 215)]
[New Thread 0x7fffec85a700 (LWP 216)]
[New Thread 0x7fffec059700 (LWP 217)]
[New Thread 0x7fffeb858700 (LWP 218)]
[New Thread 0x7fffeb057700 (LWP 219)]
[New Thread 0x7fffea856700 (LWP 220)]
[New Thread 0x7fffea055700 (LWP 221)]
[New Thread 0x7fffe9854700 (LWP 222)]
Timer Resolution for Run TimeStats is 100 ticks per second.
Opened socket on port 1234 with FD: 6
Opened socket on port 4321 with FD: 7
[New Thread 0x7ffff7fd5740 (LWP 223)]
MQ 'FreeRTOS_MQ_one_22' opened and notified
MQ 'FreeRTOS_MQ_two_22' opened and notified
Opened socket on port 2222 with FD: 11
*****TICK******
Demo UDP Socket can be tested using
*** netcat -vv localhost 1234 -u ***
UDP socket opened on port 4321
Demo UDP Socket can be tested using
*** netcat -vv localhost 4321 -u ***
TCP socket opened on port 2222
Demo TCP socket can be tested using
*** netcat -vv localhost 2222 ***
Sent to MQ: FreeRTOS_MQ_one_22
Sent to MQ: FreeRTOS_MQ_two_22
[New Thread 0x7fffe9053700 (LWP 224)]
[New Thread 0x7fffe8852700 (LWP 225)]
<- a few seconds fine
[Thread 0x7fffe9053700 (LWP 224) exited] <- FREEZING HERE
[Thread 0x7fffe8852700 (LWP 225) exited] <- FREEZING HERE

(gdb) thread apply all bt
Backtrace:
Thread 13 (Thread 0x7ffff7fd5740 (LWP 223)):
#0  0x00007ffff78c67eb in recv () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff6d6da28 in ?? () from /lib/x86_64-linux-gnu/librt.so.1
#2  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#3  0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 12 (Thread 0x7fffe9854700 (LWP 222)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737111213824) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x0000000000408482 in prvIdleTask (pvParameters=0x0) at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:2954
#7  0x0000000000405248 in prvWaitForStart (pvParams=0x65fd10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#8  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#9  0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 11 (Thread 0x7fffea055700 (LWP 221)):
#0  0x00007ffff6a6f207 in sched_yield () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x0000000000405360 in prvSuspendThread (xThreadId=140737119606528) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:548
#2  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#3  0x0000000000404e30 in vPortExitCritical () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#4  0x0000000000405ecc in xQueueGenericSend (xQueue=0x615030, pvItemToQueue=0x7fffea054540, xTicksToWait=0, xCopyPosition=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:873
#5  0x000000000040c93c in vfprints (__stream=0x7ffff6d63400 <_IO_2_1_stdout_>, __format=0x40e808 "UDP Recv in first handler: %s\n", args=0x7fffea054678) at /tmp/project/lib/Gfx/TUM_Print.c:59
#6  0x000000000040caa0 in prints (__format=0x40e808 "UDP Recv in first handler: %s\n") at /tmp/project/lib/Gfx/TUM_Print.c:74
#7  0x0000000000403452 in UDPHandlerOne (read_size=10, buffer=0x7fffe4000980 "UDP test 1", args=0x0) at /tmp/project/src/main.c:375
#8  0x000000000040da38 in aIOSocketSigHandler (signal=29, info=0x7fffea054930, context=0x7fffea054800) at /tmp/project/lib/AsyncIO/AsyncIO.c:448
#9  <signal handler called>
#10 0x00007ffff78c695b in send () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x000000000040d57d in aIOSocketPut (protocol=UDP, s_addr=0x0, port=1234, buffer=0x40ebf0 "UDP test 1", buffer_size=10) at /tmp/project/lib/AsyncIO/AsyncIO.c:332
#12 0x000000000040365e in vDemoSendTask (pvParameters=0x0) at /tmp/project/src/main.c:435
#13 0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#14 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#15 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 10 (Thread 0x7fffea856700 (LWP 220)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737127999232) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x0000000000404e30 in vPortExitCritical () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#7  0x0000000000407ae1 in xTaskResumeAll () at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1978
#8  0x00000000004072d0 in vTaskDelay (xTicksToDelay=1000) at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1190
#9  0x0000000000403757 in vMQDemoTask (pvParameters=0x0) at /tmp/project/src/main.c:458
#10 0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#11 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#12 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 9 (Thread 0x7fffeb057700 (LWP 219)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737136391936) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x0000000000404e30 in vPortExitCritical () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#7  0x0000000000407ae1 in xTaskResumeAll () at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1978
#8  0x00000000004072d0 in vTaskDelay (xTicksToDelay=10) at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1190
#9  0x0000000000403809 in vTCPDemoTask (pvParameters=0x0) at /tmp/project/src/main.c:480
#10 0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#11 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#12 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 8 (Thread 0x7fffeb858700 (LWP 218)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c5f1c in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x00007ffff78c1649 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#5  0x00007ffff78c1470 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#6  0x0000000000404e51 in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:313
#7  0x00000000004072e0 in vTaskDelay (xTicksToDelay=1000) at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1199
#8  0x000000000040356a in vUDPDemoTask (pvParameters=0x0) at /tmp/project/src/main.c:405
#9  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 7 (Thread 0x7fffec059700 (LWP 217)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737153177344) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000405235 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:499
#6  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#7  0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 6 (Thread 0x7fffec85a700 (LWP 216)):
#0  0x00007ffff78c5f1c in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff78c1649 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff78c1470 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#3  0x0000000000404e51 in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:313
#4  0x0000000000404e30 in vPortExitCritical () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#5  0x000000000040627b in xQueueGenericReceive (xQueue=0x65fc60, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1380
#6  0x000000000040c669 in xGetMouseX () at /tmp/project/lib/Gfx/TUM_Event.c:88
#7  0x0000000000402ea6 in vDrawCave () at /tmp/project/src/main.c:232
#8  0x0000000000403891 in vDemoTask1 (pvParameters=0x0) at /tmp/project/src/main.c:497
#9  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 5 (Thread 0x7fffed05b700 (LWP 215)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737169962752) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x0000000000407adc in xTaskResumeAll () at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1967
#7  0x0000000000406373 in xQueueGenericReceive (xQueue=0x6a0f10, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1438
#8  0x0000000000402d59 in vSwapBuffers (pvParameters=0x0) at /tmp/project/src/main.c:194
#9  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 4 (Thread 0x7fffed85c700 (LWP 214)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737178355456) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x000000000040637d in xQueueGenericReceive (xQueue=0x6a0fc0, pvBuffer=0x7fffed85be46, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1439
#7  0x0000000000402c46 in basicSequentialStateMachine (pvParameters=0x0) at /tmp/project/src/main.c:148
#8  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#9  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#10 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 3 (Thread 0x7ffff0386700 (LWP 212)):
#0  0x00007ffff78c5670 in sem_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff7b9672e in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#2  0x00007ffff7b96875 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#3  0x00007ffff7b4bbb1 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#4  0x00007ffff7b4b74d in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#5  0x00007ffff7b96479 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#6  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#7  0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 2 (Thread 0x7ffff0b87700 (LWP 211)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737232008960) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x000000000040637d in xQueueGenericReceive (xQueue=0x615030, pvBuffer=0x613da0 <msgToPrint.2682>, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1439
#7  0x000000000040cad8 in safePrintTask (pvParameters=0x0) at /tmp/project/lib/Gfx/TUM_Print.c:84
#8  0x0000000000405248 in prvWaitForStart (pvParams=0x616db0) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#9  0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#10 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

Thread 1 (Thread 0x7ffff7fd8740 (LWP 207)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x0000000000404cd3 in xPortStartScheduler () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:235
#2  0x000000000040793c in vTaskStartScheduler () at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1788
#3  0x00000000004042a2 in main (argc=1, argv=0x7fffffffe778) at /tmp/project/src/main.c:719
alxhoff commented 4 years ago

hmmm I can't sem to reproduce in my VM.

Thread 5 (Thread 0x7fffed05b700 (LWP 215)):
#0  0x00007ffff78c70c1 in sigwait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004052cf in prvSuspendSignalHandler (sig=10) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#2  <signal handler called>
#3  0x00007ffff78c4611 in pthread_kill () from /lib/x86_64-linux-gnu/libpthread.so.0
#4  0x0000000000405353 in prvSuspendThread (xThreadId=140737169962752) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#5  0x0000000000404eda in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#6  0x0000000000407adc in xTaskResumeAll () at /tmp/project/lib/FreeRTOS_Kernel/tasks.c:1967
#7  0x0000000000406373 in xQueueGenericReceive (xQueue=0x6a0f10, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1438
#8  0x0000000000402d59 in vSwapBuffers (pvParameters=0x0) at /tmp/project/src/main.c:194
#9  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

combined with

Thread 6 (Thread 0x7fffec85a700 (LWP 216)):
#0  0x00007ffff78c5f1c in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff78c1649 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff78c1470 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#3  0x0000000000404e51 in vPortYield () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:313
#4  0x0000000000404e30 in vPortExitCritical () at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#5  0x000000000040627b in xQueueGenericReceive (xQueue=0x65fc60, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at /tmp/project/lib/FreeRTOS_Kernel/queue.c:1380
#6  0x000000000040c669 in xGetMouseX () at /tmp/project/lib/Gfx/TUM_Event.c:88
#7  0x0000000000402ea6 in vDrawCave () at /tmp/project/src/main.c:232
#8  0x0000000000403891 in vDemoTask1 (pvParameters=0x0) at /tmp/project/src/main.c:497
#9  0x0000000000405248 in prvWaitForStart (pvParams=0x65ee60) at /tmp/project/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff78bf184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#11 0x00007ffff6a9e03d in clone () from /lib/x86_64-linux-gnu/libc.so.6

I imagine this is what is making the emulator seem frozen, not sure why it would deadlock there. Was the screen blank or just not moving?

alxhoff commented 4 years ago

Only thing I can think of is that calls to the print functions are overflowing the task stacks. I will add a set of static print message buffers to the print module such that the message buffers aren't consuming each task's stack.

alxhoff commented 4 years ago

@PhilippvK It's still hanging and I have no idea why. I added a ring buffer and then use an "atomic" (even though it's two sequential atomic operations) call to __sync_fetch_and_add to access the ring buffer offset. Idea is that I don't want to block the calling tasks at all. The back trace makes no sense as there isn't a deadlock anywhere :(

PhilippvK commented 4 years ago

Does this mean you have been able to reproduce it?

PhilippvK commented 4 years ago

Do you have your own backtrace or are you investigating the one I posted tonight?

PhilippvK commented 4 years ago

The Screen stops moving and the program does not react anymore

alxhoff commented 4 years ago

Yes. I think the problem is from the AIO callbacks as they are not FreeRTOS controlled threads. One option would be for me to scrap the use of FreeRTOS structures in TUM_Print.h and stick with a pure POSIX implementation. Clang tidy just threw a pointer dereference error so I'll quickly see if that is a problem.

alxhoff commented 4 years ago

Do you have your own backtrace or are you investigating the one I posted tonight?

Yer I have my own.


Thread 19 (Thread 0x7fffec55f740 (LWP 7960)):
#0  0x00007ffff796b5fc in recv () from /usr/lib/libc.so.6
#1  0x00007ffff7a36ee8 in ?? () from /usr/lib/librt.so.1
#2  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#3  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 18 (Thread 0x7fff9d7fa700 (LWP 7959)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  prvCheckTasksWaitingTermination () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:3148
#5  0x000055555555d595 in prvIdleTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:2930
#6  0x000055555555a1e5 in prvWaitForStart (pvParams=0x5555557a1300) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 17 (Thread 0x7fff9dffb700 (LWP 7958)):
#0  0x00007ffff795166b in sched_yield () from /usr/lib/libc.so.6
#1  0x000055555555a34e in prvSuspendThread (xThreadId=140735844169472) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:548
#2  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#3  0x0000555555559d7b in vPortExitCritical () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#4  0x000055555555af3b in xQueueGenericSend (xQueue=0x5555557ea810, pvItemToQueue=0x55555556c1c0 <rbuf_buffer+1056>, xTicksToWait=0, xCopyPosition=0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/queue.c:873
#5  0x0000555555561c73 in vfprints (__stream=0x7ffff7a2b500 <_IO_2_1_stdout_>, __format=0x555555565150 "UDP Recv in second handler: %s\n", args=0x7fff9dffa570) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/Gfx/TUM_Print.c:83
#6  0x0000555555561e14 in prints (__format=0x555555565150 "UDP Recv in second handler: %s\n") at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/Gfx/TUM_Print.c:100
#7  0x000055555555826e in UDPHandlerTwo (read_size=10, buffer=0x7fff900014c0 "UDP test 2", args=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:380
#8  0x0000555555563c24 in aIOSocketSigHandler (signal=29, info=0x7fff9dffa830, context=0x7fff9dffa700) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/AsyncIO/AsyncIO.c:448
#9  <signal handler called>
#10 0x00007ffff7df8b3c in send () from /usr/lib/libpthread.so.0
#11 0x000055555556371a in aIOSocketPut (protocol=UDP, s_addr=0x0, port=4321, buffer=0x55555556558b "UDP test 2", buffer_size=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/AsyncIO/AsyncIO.c:332
#12 0x00005555555584aa in vDemoSendTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:438
#13 0x000055555555a1e5 in prvWaitForStart (pvParams=0x5555557a1050) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#14 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#15 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 16 (Thread 0x7fff9e7fc700 (LWP 7957)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140735852562176) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555c3a0 in vTaskDelay (xTicksToDelay=1000) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:1199
#8  0x0000555555558568 in vMQDemoTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:458
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x55555580d110) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 15 (Thread 0x7fff9effd700 (LWP 7956)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140735860954880) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555c3a0 in vTaskDelay (xTicksToDelay=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:1199
#8  0x0000555555558625 in vTCPDemoTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:480
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x5555557fb4a0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 14 (Thread 0x7fff9f7fe700 (LWP 7955)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140735869347584) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555c3a0 in vTaskDelay (xTicksToDelay=1000) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:1199
#8  0x000055555555836b in vUDPDemoTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:405
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x5555557fb3c0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 13 (Thread 0x7fff9ffff700 (LWP 7954)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140735877740288) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x000055555555a1d8 in prvWaitForStart (pvParams=0x55555580d030) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:499
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140737030981376) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555b417 in xQueueGenericReceive (xQueue=0x55555584c800, pvBuffer=0x0, xTicksToWait=4294967295, xJustPeeking=0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/queue.c:1439
#8  0x000055555555865d in vDemoTask1 (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:488
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x55555580d010) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 11 (Thread 0x7fffe53d1700 (LWP 7952)):
#0  0x00007ffff7df84cf in __lll_lock_wait () from /usr/lib/libpthread.so.0
#1  0x00007ffff7df0e03 in pthread_mutex_lock () from /usr/lib/libpthread.so.0
#2  0x0000555555559d9f in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:313
#3  0x0000555555559d7b in vPortExitCritical () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:301
#4  0x000055555555af3b in xQueueGenericSend (xQueue=0x55555584c8b0, pvItemToQueue=0x0, xTicksToWait=0, xCopyPosition=0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/queue.c:873
#5  0x0000555555557b23 in vSwapBuffers (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:197
#6  0x000055555555a1e5 in prvWaitForStart (pvParams=0x55555584ca30) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 10 (Thread 0x7fffe5bd2700 (LWP 7951)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140737047766784) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555b417 in xQueueGenericReceive (xQueue=0x55555584c960, pvBuffer=0x7fffe5bd1e1e, xTicksToWait=4294967295, xJustPeeking=0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/queue.c:1439
#8  0x00005555555579d5 in basicSequentialStateMachine (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:148
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x55555584ca10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 9 (Thread 0x7fffe63d3700 (LWP 7950)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x000055555555a2a2 in prvSuspendSignalHandler (sig=10) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:524
#3  <signal handler called>
#4  0x00007ffff7df64f8 in pthread_kill () from /usr/lib/libpthread.so.0
#5  0x000055555555a341 in prvSuspendThread (xThreadId=140737056159488) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:546
#6  0x0000555555559e28 in vPortYield () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:330
#7  0x000055555555b417 in xQueueGenericReceive (xQueue=0x5555557ea810, pvBuffer=0x7fffe63d2d20, xTicksToWait=4294967295, xJustPeeking=0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/queue.c:1439
#8  0x0000555555561e92 in safePrintTask (pvParameters=0x0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/Gfx/TUM_Print.c:110
#9  0x000055555555a1e5 in prvWaitForStart (pvParams=0x55555580cff0) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:502
#10 0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#11 0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 8 (Thread 0x7fffe6bd4700 (LWP 7949)):
#0  0x00007ffff795fbb6 in ppoll () from /usr/lib/libc.so.6
#1  0x00007fffec51a0e3 in pa_mainloop_poll () from /usr/lib/libpulse.so.0
#2  0x00007fffec524301 in pa_mainloop_iterate () from /usr/lib/libpulse.so.0
#3  0x00007ffff7ee0687 in ?? () from /usr/lib/libSDL2-2.0.so.0
#4  0x00007ffff7e26ff6 in ?? () from /usr/lib/libSDL2-2.0.so.0
#5  0x00007ffff7e76f4f in ?? () from /usr/lib/libSDL2-2.0.so.0
#6  0x00007ffff7f04c9a in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 7 (Thread 0x7fffec5b1700 (LWP 7948)):
#0  0x00007ffff795fbb6 in ppoll () from /usr/lib/libc.so.6
#1  0x00007fffec51a0e3 in pa_mainloop_poll () from /usr/lib/libpulse.so.0
#2  0x00007fffec524301 in pa_mainloop_iterate () from /usr/lib/libpulse.so.0
#3  0x00007fffec5243b1 in pa_mainloop_run () from /usr/lib/libpulse.so.0
#4  0x00007ffff7ee0990 in ?? () from /usr/lib/libSDL2-2.0.so.0
#5  0x00007ffff7e76f4f in ?? () from /usr/lib/libSDL2-2.0.so.0
#6  0x00007ffff7f04c9a in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 6 (Thread 0x7fffe77fe700 (LWP 7947)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 5 (Thread 0x7fffe7fff700 (LWP 7946)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 4 (Thread 0x7fffecdb2700 (LWP 7945)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 5 (Thread 0x7fffe7fff700 (LWP 7946)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 4 (Thread 0x7fffecdb2700 (LWP 7945)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
--Type <RET> for more, q to quit, c to continue without paging--
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 3 (Thread 0x7fffed5b3700 (LWP 7944)):
#0  0x00007ffff7df4cf5 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1  0x00007ffff4addbfc in ?? () from /usr/lib/dri/iris_dri.so
#2  0x00007ffff4add7f8 in ?? () from /usr/lib/dri/iris_dri.so
#3  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#4  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 2 (Thread 0x7ffff71ff700 (LWP 7943)):
#0  0x00007ffff7df77b4 in do_futex_wait.constprop () from /usr/lib/libpthread.so.0
#1  0x00007ffff7df78a8 in __new_sem_wait_slow.constprop.0 () from /usr/lib/libpthread.so.0
#2  0x00007ffff7f05564 in ?? () from /usr/lib/libSDL2-2.0.so.0
#3  0x00007ffff7f056bd in ?? () from /usr/lib/libSDL2-2.0.so.0
#4  0x00007ffff7e775b8 in ?? () from /usr/lib/libSDL2-2.0.so.0
#5  0x00007ffff7e76f4f in ?? () from /usr/lib/libSDL2-2.0.so.0
#6  0x00007ffff7f04c9a in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0x00007ffff7dee46f in start_thread () from /usr/lib/libpthread.so.0
#8  0x00007ffff796a3d3 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x7ffff7200b80 (LWP 7937)):
#0  0x00007ffff78a7ba2 in sigtimedwait () from /usr/lib/libc.so.6
#1  0x00007ffff7df932c in sigwait () from /usr/lib/libpthread.so.0
#2  0x0000555555559bff in xPortStartScheduler () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/portable/GCC/Posix/port.c:235
#3  0x000055555555ca2b in vTaskStartScheduler () at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/lib/FreeRTOS_Kernel/tasks.c:1788
#4  0x0000555555559179 in main (argc=1, argv=0x7fffffffda98) at /home/alxhoff/git/GitHub/FreeRTOS-Emulator/src/main.c:723
alxhoff commented 4 years ago

image So after doing this for 30 minutes I believe I know the problem. I think that it's as I mentioned before that the AIO thread callbacks are not FreeRTOS threads and issues can occur when collisions happen during xQueueSend that the scheduler fails as the threads are not managed by it. I think I need to remove all FreeRTOS stuff from TUM_Print

alxhoff commented 4 years ago

And I think an easy solution is to attach a posix mutex to the ring buffer that handles the print messages and then just attach a posix conditional to the safeprint Task

alxhoff commented 4 years ago

@PhilippvK I believe this is also finally done. If i remember correctly it used to hang after about ~2 mins.

alxhoff commented 4 years ago

@PhilippvK seems stable for me in my VM

PhilippvK commented 4 years ago

Same here