Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/lib: print_stack_usage_metric called with misaligned stack #20492

Open
LP-HAW opened this issue Mar 20, 2024 · 0 comments
Open

core/lib: print_stack_usage_metric called with misaligned stack #20492

LP-HAW opened this issue Mar 20, 2024 · 0 comments
Assignees

Comments

@LP-HAW
Copy link
Contributor

LP-HAW commented Mar 20, 2024

Description

On the hifive1b board many tests end in a kernel panic because of an unaligned access to memory.
This is only observable when running make term instead of make test.

I think this is because in main_trampoline the print_stack_usage_metric function is called with a potentially misaligned idle_stack.

print_stack_usage_metric("idle", idle_stack, THREAD_STACKSIZE_IDLE);

Steps to reproduce the issue

Build tests/bench/thread_yield_pingpong for hifive1b and confirm the stacks are misaligned.

$ cd tests/bench/thread_yield_pingpong
$ BOARD=hifive1b make
$ riscv-none-elf-nm -S bin/hifive1b/tests_thread_yield_pingpong.elf | grep 'idle_stack\|main_stack'
800005dd 00000100 b idle_stack
800006dd 00000500 b main_stack

Run the test with make term

$ BOARD=hifive1b make term
2024-03-20 12:08:41,103 # Help: Press s to start test, r to print it is ready
s
2024-03-20 12:08:48,859 # START
2024-03-20 12:08:48,863 # main(): This is RIOT! (Version: 2024.04-devel-440-ge3ce7)
2024-03-20 12:08:48,864 # main starting
2024-03-20 12:08:49,867 # { "result" : 673289, "ticks" : 475 }
2024-03-20 12:08:49,869 # Unhandled trap:
2024-03-20 12:08:49,870 #   mcause: 0x4
2024-03-20 12:08:49,872 #   mepc:   0x2001056e
2024-03-20 12:08:49,873 #   mtval:  0x800005dd
2024-03-20 12:08:49,875 # *** RIOT kernel panic:
2024-03-20 12:08:49,877 # Unhandled trap
2024-03-20 12:08:49,877 # 
2024-03-20 12:08:49,878 # *** halted.
2024-03-20 12:08:49,878 #

Versions

GCC:

$ riscv-none-elf-gcc --version
riscv-none-elf-gcc (xPack GNU RISC-V Embedded GCC x86_64) 13.2.0
@maribu maribu self-assigned this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants