masayuki2009 commented on issue #802: URL: https://github.com/apache/incubator-nuttx/issues/802#issuecomment-616856052
> @xiaoxiang781216 I've just confirmed the deadlock. I will take a look at
what is happening tomorrow.
```
(gdb) target extended-remote:1234
Remote debugging using :1234
up_testset () at armv7-a/arm_testset.S:120
120 mov r0, #SP_LOCKED
(gdb) info thread
Id Target Id Frame
* 1 Thread 1 (CPU#0 [running]) up_testset () at armv7-a/arm_testset.S:120
2 Thread 2 (CPU#1 [running]) 0x10802eb0 in spin_trylock_wo_note () at
semaphore/spinlock.c:178
3 Thread 3 (CPU#2 [halted ]) 0x108081cc in up_idle () at
chip/imx_idle.c:59
4 Thread 4 (CPU#3 [halted ]) 0x108081cc in up_idle () at
chip/imx_idle.c:59
(gdb) where
#0 up_testset () at armv7-a/arm_testset.S:120
#1 0x10802e70 in spin_lock (lock=lock@entry=0x10829379 <g_cpu_paused+1>
"\001") at semaphore/spinlock.c:89
#2 0x10801250 in up_cpu_pause (cpu=cpu@entry=1) at
armv7-a/arm_cpupause.c:282
#3 0x10813164 in sched_addreadytorun (btcb=btcb@entry=0x10836eb0) at
sched/sched_addreadytorun.c:280
#4 0x10808148 in up_unblock_task (tcb=0x10836eb0) at
armv7-a/arm_unblocktask.c:102
#5 0x10802e28 in nxsem_post (sem=sem@entry=0x10837f94) at
semaphore/sem_post.c:165
#6 0x10804068 in nxtask_exitwakeup (status=277052944, tcb=0x10837e10) at
task/task_exithook.c:547
#7 nxtask_exithook (tcb=0x10837e10, status=status@entry=0,
nonblocking=nonblocking@entry=0 '\000') at task/task_exithook.c:677
#8 0x10803438 in exit (status=0) at task/exit.c:96
#9 0x1080341c in nxtask_start () at task/task_start.c:151
#10 0x00000000 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 2)]
#0 0x10802eb0 in spin_trylock_wo_note () at semaphore/spinlock.c:178
178 return SP_UNLOCKED;
(gdb) where
#0 0x10802eb0 in spin_trylock_wo_note () at semaphore/spinlock.c:178
#1 0x10802638 in irq_waitlock (cpu=1) at irq/irq_csection.c:137
#2 0x10802734 in enter_critical_section () at irq/irq_csection.c:345
#3 0x10806154 in ramlog_addchar (priv=priv@entry=0x10829130 <g_sysdev>,
ch=ch@entry=97 'a') at syslog/ramlog.c:230
#4 0x10806478 in ramlog_putc (ch=97) at syslog/ramlog.c:749
#5 0x10814c48 in syslogstream_putc (ch=<optimized out>, this=<optimized
out>) at syslog/syslog_stream.c:174
#6 syslogstream_putc (this=0x1082fb8c <g_irqstack_alloc+4004>, ch=97) at
syslog/syslog_stream.c:130
#7 0x10806d60 in vsprintf_internal (arglist=0x0, numargs=0, ap=...,
fmt=<optimized out>, stream=0x1082fb8c <g_irqstack_alloc+4004>) at
stdio/lib_libvsprintf.c:909
#8 lib_vsprintf (stream=0x1082fb8c <g_irqstack_alloc+4004>,
stream@entry=0x1082fb84 <g_irqstack_alloc+3996>, fmt=fmt@entry=0x10820de6 "%s:
cpu = %d, irq %d.\n", ap=...) at stdio/lib_libvsprintf.c:1278
#9 0x10814c1c in nx_vsyslog (priority=priority@entry=3, fmt=0x10820de6 "%s:
cpu = %d, irq %d.\n", fmt@entry=0x10807434 <vsyslog+36>
"\f\320\215\342\004\360\235\344T\221\202\020\016", ap=0x1082fbac
<g_irqstack_alloc+4036>, ap@entry=0x1082fba4 <g_irqstack_alloc+4028>) at
syslog/vsyslog.c:148
#10 0x10807434 in vsyslog (priority=priority@entry=3,
fmt=fmt@entry=0x10807434 <vsyslog+36>
"\f\320\215\342\004\360\235\344T\221\202\020\016", ap=..., ap@entry=...) at
syslog/lib_syslog.c:84
#11 0x10807458 in syslog (priority=priority@entry=3, fmt=0x10820de6 "%s: cpu
= %d, irq %d.\n") at syslog/lib_syslog.c:116
#12 0x10800dd8 in arm_decodeirq (regs=0x10833c28 <g_cpu1_idlestack+1832>) at
armv7-a/arm_gicv2.c:397
```
As you can see, the thread2 running on cpu#1 is in interrupt context.
However, as @patacongo pointed out, enter_critical_section() processes as if
it were in normal tasking environment, because _err() was called before setting
CURRENT_REGS.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
