Skip to content

mps2_an385 crashes if CONFIG_INIT_STACKS=y and CONFIG_COVERAGE=y #15794

@andrewboie

Description

@andrewboie

If both of these configs get enabled, we get a bus fault:

***** BUS FAULT *****
  Precise data bus error
  BFAR Address: 0xaaaaaaaa
***** Hardware exception *****
Current thread ID = 0x2000ca54
Faulting instruction address = 0x8656
Fatal fault in thread 0x2000ca54! Aborting.
***** USAGE FAULT *****
  Illegal load of EXC_RETURN into PC
***** Hardware exception *****
Current thread ID = 0x20009a14
Faulting instruction address = 0x5bcd
Fatal fault in thread 0x20009a14! Aborting.
***** MPU FAULT *****
  Data Access Violation
  MMFAR Address: 0x64
***** Hardware exception *****
Current thread ID = 0x00000000
Faulting instruction address = 0x5bf8
Fatal fault in ISR! Spinning...

Note that the thread ID information is bogus since we are in early boot context.

The crash happens in the call to memset() in z_new_thread_init() when it tries to write 0xAA to the stack buffer (which is what CONFIG_INIT_STACKS does) for the main thread.

#0  memset (buf=0x2000ab30 <_main_stack>, c=170, n=8192)
    at /home/apboie/projects/zephyr3/zephyr/lib/libc/minimal/source/string/string.c:290
#1  0x00006c2c in z_new_thread_init (thread=0x20009a14 <_main_thread_s>, 
    pStack=0x2000ab30 <_main_stack> "", stackSize=8192, prio=0, options=1)
    at /home/apboie/projects/zephyr3/zephyr/kernel/include/kernel_structs.h:222
#2  0x00006cea in z_new_thread (thread=0x20009a14 <_main_thread_s>, stack=0x2000ab30 <_main_stack>, 
    stackSize=8192, pEntry=0xc271 <bg_thread_main>, parameter1=0x0 <crc32_ieee>, 
    parameter2=0x0 <crc32_ieee>, parameter3=0x0 <crc32_ieee>, priority=0, options=1)
    at /home/apboie/projects/zephyr3/zephyr/arch/arm/core/thread.c:100
#3  0x0001003c in z_setup_new_thread (new_thread=0x20009a14 <_main_thread_s>, 
    stack=0x2000ab30 <_main_stack>, stack_size=8192, entry=0xc271 <bg_thread_main>, 
    p1=0x0 <crc32_ieee>, p2=0x0 <crc32_ieee>, p3=0x0 <crc32_ieee>, prio=0, options=1, 
    name=0x14354 "main") at /home/apboie/projects/zephyr3/zephyr/kernel/thread.c:362
#4  0x0000c4e0 in prepare_multithreading (dummy_thread=0x2000ca54 <_main_stack+7972>)
    at /home/apboie/projects/zephyr3/zephyr/kernel/init.c:368
#5  0x0000c6d0 in z_cstart () at /home/apboie/projects/zephyr3/zephyr/kernel/init.c:513
#6  0x0000776e in _PrepC () at /home/apboie/projects/zephyr3/zephyr/arch/arm/core/cortex_m/prep_c.c:187
#7  0x00007460 in __start () at /home/apboie/projects/zephyr3/zephyr/arch/arm/core/cortex_m/reset.S:75

To reproduce, add the lines:

CONFIG_COVERAGE=y
CONFIG_INIT_STACKS=y

to samples/hello_world/prj.conf and run on mps2_an385.
First noticed with tests/kernel/mem_protect/userspace, but not specific to that test

Metadata

Metadata

Assignees

Labels

area: ARMARM (32-bit) ArchitecturebugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions