Skip to content

posix: timers: incorrect pointer passed to k_mem_slab_free() #88194

@cfriedt

Description

@cfriedt

Describe the bug
The implementation of timer_create() in 53f1af9 improperly called k_mem_slab_free() on the address of the struct timer_obj * timer object instead of the value of the pointer itself.

Please also mention any information which could help others to understand
the problem you're facing:

  • What target platform are you using? all
  • What have you tried to diagnose or workaround this issue? root-caused it
  • Is this a regression? No, it's a bug that has been present since the code was added.

To Reproduce
Steps to reproduce the behavior:

  1. Apply the change in posix: timers: correct pointer passed to k_mem_slab_free() #88193 except for the last two commits
  2. Observe error

Expected behavior
Tests should pass

Impact
This could cause otherwise correct code to fault.

Logs and console output

west build -p auto -b qemu_riscv64 -t run tests/posix/timers
...
*** Booting Zephyr OS build v4.1.0-1983-g69fac8647009 ***
Running TESTSUITE posix_timers
===================================================================
START - test_CLOCK_MONOTONIC__SIGEV_SIGNAL
 PASS - test_CLOCK_MONOTONIC__SIGEV_SIGNAL in 2.117 seconds
===================================================================
START - test_CLOCK_MONOTONIC__SIGEV_THREAD
ASSERTION FAIL [0] @ WEST_TOPDIR/zephyr/kernel/mem_slab.c:273
        Invalid memory pointer provided
E: 
E:  mcause: 11, Environment call from M-mode
E:   mtval: 0
E:      a0: 0000000000000004    t0: 0000000000000000
E:      a1: 0000000000000111    t1: 000000000000004c
E:      a2: 0000000080014338    t2: 0000000000000044
E:      a3: 0000000080012e20    t3: 000000000000002a
E:      a4: 0000000000000000    t4: 000000000000002e
E:      a5: 00000000800132a0    t5: 000000000000007f
E:      a6: 0000000000000002    t6: 0000000000000010
E:      a7: 0000000000000009
E:      sp: 0000000080014370
E:      ra: 00000000800065bc
E:    mepc: 00000000800024b8
E: mstatus: 0000000a00021880
E: 
E:      s0: 0000000080017570    s6: 0000000000000000
E:      s1: 0000000000000000    s7: 0000000000000000
E:      s2: 0000000080019230    s8: 0000000000000000
E:      s3: 0000000080014400    s9: 0000000000000000
E:      s4: 000000008000ea30   s10: 0000000000000000
E:      s5: 0000000000000008   s11: 0000000000000000
E: 
E: call trace:
E:       0: sp: 0000000080014370 ra: 00000000800024b8
E:       1: sp: 00000000800143a0 ra: 00000000800037e2
E:       2: sp: 00000000800143e0 ra: 0000000080001dac
E:       3: sp: 0000000080014408 ra: 0000000080001b68
E:       4: sp: 0000000080014430 ra: 0000000080002c1c
E:       5: sp: 0000000080014440 ra: 000000008000024e
E:       6: sp: 0000000080014460 ra: 0000000080008b36
E:       7: sp: 0000000080014480 ra: 000000008000496a
E: 
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Current thread: 0x80012e20 (test_CLOCK_MONOTONIC__SIGEV_THR)
E: Halting system

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephr SDK v0.17.0
  • Commit SHA: 207a048

Additional context

Metadata

Metadata

Assignees

Labels

area: POSIXPOSIX API LibrarybugThe 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