zephyr: Zephyr 3.7.0-rc1 issue: heap failure

Discussed in https://github.com/zephyrproject-rtos/zephyr/discussions/75077

<div type='discussions-op-text'>

Originally posted by RobMeades June 27, 2024

I’m testing the move from 3.6.0 to 3.7.0 and one of our tests (running on an STM32F7), which has run happily for years on Zephyr (3.6.0 and earlier), Linux, Windows, etc, is now failing when it tries to free a memory block:

E: ***** BUS FAULT *****
E:   Imprecise data bus error
E: r0/a1:  0x20028400  r1/a2:  0x00002dbf  r2/a3:  0x00003fff
E: r3/a4:  0x00003fff r12/ip:  0x200142e0 r14/lr:  0x0806adc1
E:  xpsr:  0x81000000
E: r4/v1:  0x20028400  r5/v2:  0x0000059b  r6/v3:  0x00002cd8
E: r7/v4:  0x2002b0d8  r8/v5:  0x00000000  r9/v6:  0x00000000
E: r10/v7: 0x00000000  r11/v8: 0x00000000    psp:  0x20051f08
E: EXC_RETURN: 0xfffffffd
E: Faulting instruction address (r15/pc): 0x0806aea6
E: >>> ZEPHYR FATAL ERROR 26: Unknown error on CPU 0
E: Current thread: 0x20021b90 (main)
### Dumping current thread (main) ###
    0x0806aea6: free_chunk                   /home/zephyr_native-v3.7.0-rc1/zephyr/lib/heap/heap.c:144 (discriminator 1)
    0x0806adbc: free_list_remove             /home/zephyr_native-v3.7.0-rc1/zephyr/lib/heap/heap.c:64
    0x08042e2c: sys_heap_free                /home/zephyr_native-v3.7.0-rc1/zephyr/lib/heap/heap.c:197
    0x08056bf6: k_heap_free                  /home/zephyr_native-v3.7.0-rc1/zephyr/kernel/kheap.c:153
    0x08077a96: k_free                       /home/zephyr_native-v3.7.0-rc1/zephyr/kernel/mempool.c:54

Has anyone else seen anything like this and are there any heap debug options (guards etc.) in Zephyr that would help us track down what’s going on?</div>

From the template

Target platform: nucleo_f767zi What have you tried to diagnose or workaround this issue: nothing yet, that is essentially my question, what facilities does Zephyr provide to debug heap issues. Is this a regression: yes, tag v3.6.0 good, tag v3.7.0-rc1 bad.

To Reproduce I don’t expect you to be able to reproduce this, but…

  1. Clone https://github.com/u-blox/ubxlib.
  2. Follow installation instructions for native Zephyr.
  3. Follow the instructions to build and flash our standard “runner” test build for an STM32-based Zephyr platform.
  4. Connect a debugger to a nucleo_f767zi board via SWD.
  5. Download the binary to this board.
  6. Reset the board and watch the SWD output and you will see that the test portEventQueue() throws the error.

Expected behavior No exception should occur, freeing memory should succeed without an exception.

Impact Can’t move to Zephyr 3.7.0.

Logs and console output See above.

Environment:

Additional context Build directory, containing CMakeLists.txt, prj.conf and the .overlay files can be found here: https://github.com/u-blox/ubxlib/tree/master/port/platform/zephyr/runner_stm32, the only addition to what is there being CONFIG_DCACHE=n for 3.7.0-rc1 which was recommended here: https://github.com/zephyrproject-rtos/zephyr/discussions/75032. Note that we build and run the same thing but for an STM32U5 (nucleo_u575zi_q board) and that passes the test fine, no exception.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

@RobMeades please use the bug report template, thanks!