phoenix-rtos / phoenix-rtos-project

Sample project using Phoenix-RTOS
https://phoenix-rtos.com
BSD 3-Clause "New" or "Revised" License
45 stars 32 forks source link

lib_printf under threads spinlock causes deadlock when klog is enabled #539

Closed xvuko closed 1 year ago

xvuko commented 2 years ago

Example stacktrace when stack canary check fails:

0 hal_spinlockSet (spinlock=spinlock@entry=0x20000e6c <threads_common+4>, sc=0x0, sc@entry=0x2002509c) at phoenix-rtos-kernel/hal/armv7m/spinlock.c:26

1 proc_current () at phoenix-rtos-kernel/proc/threads.c:658

2 _proc_lockSet (lock=lock@entry=0x20000888 <log_common+2072>, interruptible=interruptible@entry=0, scp=scp@entry=0x200250dc) at phoenix-rtos-kernel/proc/threads.c:1418

3 proc_lockSet (lock=lock@entry=0x20000888 <log_common+2072>) at phoenix-rtos-kernel/proc/threads.c:1468

4 log_write (data=data@entry=0x20025114 "\033", len=len@entry=1) at phoenix-rtos-kernel/log/log.c:347

5 lib_putch (s=) at phoenix-rtos-kernel/lib/printf.c:142

6 lib_printf (format=0x801bf64 "proc: User stack corrupted path=%s, pid=%d, tid=%d\n") at phoenix-rtos-kernel/lib/printf.c:314

7 threads_schedule (n=, context=0x200251b0, arg=) at phoenix-rtos-kernel/proc/threads.c:632

agkaminski commented 1 year ago

Fixed in https://github.com/phoenix-rtos/phoenix-rtos-kernel/commit/8b528dca7118c6e08be6de3967e8dccc799c40f1