Skip to content

xtimer: valgrind complains about uninitialized variables for jumps #4372

@miri64

Description

@miri64

Running tests/xtimer_msg_receive_timeout in valgrind yields the following result:

main(): This is RIOT! (Version: 2015.12-devel-718-gc143-beutlin-pkg/port/lwip)
==7035== Conditional jump or move depends on uninitialised value(s)
==7035==    at 0x804BF92: _is_set (sys/xtimer/xtimer_core.c:53)
==7035==    by 0x804C398: xtimer_remove (sys/xtimer/xtimer_core.c:244)
==7035==    by 0x804C114: xtimer_set (sys/xtimer/xtimer_core.c:122)
==7035==    by 0x804BCB6: xtimer_set_msg (sys/xtimer/xtimer.c:124)
==7035==    by 0x804B99D: main (tests/xtimer_msg_receive_timeout/main.c:34)
==7035==  Uninitialised value was created by a stack allocation
==7035==    at 0x804B949: main (tests/xtimer_msg_receive_timeout/main.c:27)
==7035== 
==7035== Conditional jump or move depends on uninitialised value(s)
==7035==    at 0x804BF9C: _is_set (sys/xtimer/xtimer_core.c:53)
==7035==    by 0x804C398: xtimer_remove (sys/xtimer/xtimer_core.c:244)
==7035==    by 0x804C114: xtimer_set (sys/xtimer/xtimer_core.c:122)
==7035==    by 0x804BCB6: xtimer_set_msg (sys/xtimer/xtimer.c:124)
==7035==    by 0x804B99D: main (tests/xtimer_msg_receive_timeout/main.c:34)
==7035==  Uninitialised value was created by a stack allocation
==7035==    at 0x804B949: main (tests/xtimer_msg_receive_timeout/main.c:27)
==7035== 
Message received: 44
Timeout!
Message received: 44
Timeout!

This is due to target and/or long_target being checked early on an xtimer_remove() in xtimer_set() and the xtimer not being used yet. It works for now because the timer is set in the BSS section, which results in the timer always being 0 in the beginning, but it might lead to unwanted behavior.

Metadata

Metadata

Assignees

Labels

Area: timersArea: timer subsystemsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions