Skip to content

software hang at printk with "CONFIG_STACK_CANARIES=y" #1603

@zephyrbot

Description

@zephyrbot

Reported by Javier B Perez:

Configuration

x86
arduino_101
micro

Bug detailed description

Run sample test code "zephyr/tests/kernel/test_stackprot/microkernel" @Arduino_101 board, software hang at printk.
NOTE1: If disable "CONFIG_STACK_CANARIES=y", issue is not observed.
NOTE2: The issue is not observed with qemu_x86, even with "CONFIG_STACK_CANARIES=y"

Testcase to Reproduce

sample test code "zephyr/tests/kernel/test_stackprot/microkernel"

Steps to Reproduce

  1. cd zephyr
  2. source zephyr-env.sh
  3. cd tests/kernel/test_stackprot/microkernel
  4. make pristine;make BOARD=arduino_101 flash
  5. verify from UART output nothing.
(gdb) b RegressionTask 
Breakpoint 1 at 0x400332af: file /home/sharron/workspace/views/iot/forto-collab/samples/microkernel/test/test_stackprot/src/stackprot.c, line 145. 
(gdb) c 
Continuing. 
target running 
target is still running! 
hit hardware breakpoint (hwreg=0) at 0x400332af 

Breakpoint 1, RegressionTask () 
at /home/sharron/workspace/views/iot/forto-collab/samples/microkernel/test/test_stackprot/src/stackprot.c:145 
145 { 
(gdb) c 

software hang here. Press ctrl+c to stop, and check from gdb:

^C 
Program received signal SIGINT, Interrupt. 
_vprintk (ap=0xa800a000 <__REGRESSIONTASK_stack+2024> "\353\067\003@\020\240", 
fmt=0x40033816 "%s\n") 
at /home/sharron/workspace/views/iot/forto-collab/misc/printk.c:79 
79 while (*fmt) { 
(gdb) l 
74 { 
75 int might_format = 0; /* 1 if encountered a '%' */ 
76 
77 /* fmt has already been adjusted if needed */ 
78 
79 while (*fmt) { 
80 if (!might_format) { 
81 if (*fmt != '%') { 
82 _char_out((int)*fmt); 
83 } else { 
(gdb) p *fmt 
$1 = 37 '%' 
(gdb) bt 
Python Exception <type 'exceptions.ImportError'> No module named gdb.frames: 
<span>#</span>0 _vprintk ( 
ap=0xa800a000 <__REGRESSIONTASK_stack+2024> "\353\067\003@\020\240", 
fmt=0x40033816 "%s\n") 
at /home/sharron/workspace/views/iot/forto-collab/misc/printk.c:79 
<span>#</span>1 printk (fmt=0x0) 
at /home/sharron/workspace/views/iot/forto-collab/misc/printk.c:165 
<span>#</span>2 0x400332af in AlternateTask () 
at /home/sharron/workspace/views/iot/forto-collab/samples/microkernel/test/test_stackprot/src/stackprot.c:126 
<span>#</span>3 0xa800a004 in __REGRESSIONTASK_stack () 
<span>#</span>4 0x400332c1 in RegressionTask () 
at /home/sharron/workspace/views/iot/forto-collab/samples/microkernel/test/test_stackprot/src/stackprot.c:146 
<span>#</span>5 0x400337eb in ?? () 
Backtrace stopped: previous frame inner to this frame (corrupt stack?) 
(gdb) 

Expected Result

UART output:
PROJECT EXECUTION SUCCESSFUL

Actual Result

UART output nothing, software hang at printk.

User Impact

When app call printk with stack protection enabled, software hang.

(Imported from Jira ZEP-3)

Metadata

Metadata

Assignees

Labels

area: KernelbugThe issue is a bug, or the PR is fixing a bugpriority: highHigh impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions