#2993 closed defect (fixed)

SMP assert in _Thread_Executing in libdebugger

Reported by: Chris Johns Owned by: joel.sherrill@…
Priority: normal Milestone: 5.1
Component: score Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The target code in libdebugger has support to recover from exceptions related to invalid memory accesses. GDB may request the server access memory on the target that results in an exception. The exception occurs on the server's remote connection thread and the server needs to recover and return and error to GDB.

Running the debugger01 test with an SMP build of RTEMS and libbsd for xilinx_zedboard and issuing bt in GDB results in:

*** LIBBSD DEBUGGER 1 TEST ***                                                                                                                                                                                                                                                                            [144/1950]
shell:cannot set terminal attributes(/dev/console)

RTEMS Shell on /devn/ecxounss0o:l e<.R TUEsMeS  'Nheexlups'  dteov ilcies>t
 ccogmemma0n:d s<.C
adence CGEM Gigabit Ethernet Interface> on nexus0
miibus0: <MII bus> on cgem0
[/] # e1000phy0: <Marvell 88E1512 Gigabit PHY> PHY 0 on miibus0
e1000phy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
cgem0: Ethernet address: fa:69:35:9e:04:2f
zy7_slcr0: <Zynq-7000 slcr block> on nexus0
[zone: udpcb] kern.ipc.maxsockets limit reached
notice: cgem0: link state changed to DOWN
add host 10.10.5.1: gateway cgem0
add net default: gateway 10.10.5.1
rtems-db: remote running
rtems-db: tcp remote: listing on port: 1122
notice: cgem0: link state changed to UP

rtems-db: tcp remote: connect host: 10.10.5.2
rtems-db: arm debug: (v3.0) ARMv7 [v7, all CP14 registers] breakpoints:5 watchpoints:3
assertion "cpu_self->thread_dispatch_disable_level != 0 || _ISR_Get_level() != 0" failed: file "../../cpukit/../../../xilinx_zynq_zedboard/lib/include/rtems/score/percpu.h", line 630, function: _Per_CPU_Get

If I enable TARGET_DEBUG in libdebugger and apply the attached patch I can create the assert with DIE_ON_ASSERT set to 1. The output is:

 rtems-db: tcp remote: connect host: 10.10.5.2
rtems-db: arm debug: (v3.0) ARMv7 [v7, all CP14 registers] breakpoints:5 watchpoints:3
[} frame = 005664EC sig=1 vector=4 ifsr=00000000 pra=0024173A
[}  R0 = 00000158  R1 = 00000004  R2 = 00000001  R3 = 0041AB64
[}  R4 = 00000158  R5 = 00000004  R6 = 00000000  R7 = 005606A4
[}  R8 = 00000016  R9 = 00000001 R10 = 00000006 R11 = 0041AB64
[} R12 = 00560658  SP = 00566540  LR = 00000FFD  PC = 00241736
[}  CPSR = 08010173 ----Q--A-FT GE:0 IT:01 M:13 SVC
[} target exception: 0 0 0
assertion "cpu_self->thread_dispatch_disable_level != 0 || _ISR_Get_level() != 0" failed: file "../../cpukit/../../../xilinx_zynq_zedboard/lib/include/rtems/score/percpu.h", line 630, function: _Per_CPU_Get

and set to {{{0}}:

rtems-db: tcp remote: connect host: 10.10.5.2
rtems-db: arm debug: (v3.0) ARMv7 [v7, all CP14 registers] breakpoints:5 watchpoints:3
[} frame = 005664EC sig=1 vector=4 ifsr=00000000 pra=0024173A
[}  R0 = 00000158  R1 = 00000004  R2 = 00000001  R3 = 0041AB64
[}  R4 = 00000158  R5 = 00000004  R6 = 00000000  R7 = 005606A4
[}  R8 = 00000016  R9 = 00000001 R10 = 00000006 R11 = 0041AB64
[} R12 = 00560658  SP = 00566540  LR = 00000FFD  PC = 00241736
[}  CPSR = 08010173 ----Q--A-FT GE:0 IT:01 M:13 SVC
[} target exception: 0 0 0
[} tid:0A01000A: thread:0041F5B0 frame:005664EC
[} server access fault
[} frame = 005664EC sig=1 vector=4 ifsr=00000000 pra=0024173A
[}  R0 = 00000158  R1 = 00000004  R2 = 00000001  R3 = 0041AB64
[}  R4 = 00000158  R5 = 00000004  R6 = 00000000  R7 = 005606A4
[}  R8 = 00000016  R9 = 00000001 R10 = 00000006 R11 = 0041AB64
[} R12 = 00560658  SP = 00566540  LR = 00000FFD  PC = 00241736
[}  CPSR = 08010173 ----Q--A-FT GE:0 IT:01 M:13 SVC
[} target exception: 0 0 0
[} tid:0A01000A: thread:0041F5B0 frame:005664EC
[} server access fault

The following lines first two values are cpu_self->thread_dispatch_disable_level and _ISR_Get_level() which are both 0 so I cannot see a reason the assert is happening:

[} target exception: 0 0 0

Attachments (1)

die-on-assert.patch (2.5 KB) - added by Chris Johns on 04/14/17 at 06:02:48.
Die on assert patch to test.

Download all attachments as: .zip

Change History (7)

Changed on 04/14/17 at 06:02:48 by Chris Johns

Attachment: die-on-assert.patch added

Die on assert patch to test.

comment:1 Changed on 04/15/17 at 00:44:35 by Chris Johns <chrisj@…>

In b53ad46/rtems:

libdebugger: Work around assert when using _Thread_Executing.

Using _Thread_Executing with RTEMS_DEBUG results in an assert if
the server accesses invalid memory.

Updates #2993.

comment:2 Changed on 05/02/17 at 05:27:20 by Sebastian Huber

What prevents a thread dispatch in this context?

comment:3 Changed on 05/02/17 at 06:27:02 by Chris Johns

I think it was the mode and attributes being the wrong way around in the create call.

Maybe the create call should detect this and return an error rather than the internal error.

comment:4 Changed on 05/02/17 at 14:17:14 by Joel Sherrill

It would take making the attribute and mode bits mutually exclusive so overlap can be detected. I considered this also. We would have to be careful to document/check that they stay overlapping.

comment:5 Changed on 08/24/17 at 07:30:17 by Sebastian Huber

Resolution: fixed
Status: newclosed

comment:6 Changed on 11/09/17 at 06:27:14 by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.