Fix: hlist iteration relies on undefined behavior
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 20 Apr 2021 20:07:54 +0000 (16:07 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Apr 2021 12:33:21 +0000 (08:33 -0400)
commit6470d06d0e4b219b5aeb3e2473e178a7f95b5b8f
treef0439dc34ac94bc63317a5cddfb545998a98f8bf
parent9629f99c3bfdf7dd58b73035ccc8b4c59224c488
Fix: hlist iteration relies on undefined behavior

Comparing an offset from an object with NULL is undefined behavior
and the compiler may assume that this is never true.

This is indeed what is observed with gcc-10 miscompiling
cds_hlist_for_each_entry_rcu_2().

Fix this by introducing cds_hlist_entry_safe() rather than open-coding
the NULL check comparisons, and move cds_hlist_for_each_entry_2()
and cds_hlist_for_each_entry_safe_2() to this scheme as well.

Fixes: #1308
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ief3531cf04e54b6dae05eb28a6822adfa141fdeb
include/urcu/hlist.h
include/urcu/rcuhlist.h
This page took 0.025054 seconds and 4 git commands to generate.