On Sat, Oct 03, 2020 at 09:19:25AM -0700, Paul E. McKenney wrote: > On Sat, Oct 03, 2020 at 12:28:47PM +0800, Junchang Wang wrote: [ . . . ] > But sadly, this change does not fix this bug: > > $ ./hash_bkt_hazptr --schroedinger --nreaders 1 --duration 1000 --updatewait 0 --nbuckets 8192 --elems/writer 8192 > Segmentation fault (core dumped) > > Can't have everything. ;-) > > It appears that hashtorture manages to fail to call the per-thread > hazard-pointers initialization on some paths, so it is no surprise > that Junchang's fix doesn't fix this bug. Thanx, Paul ------------------------------------------------------------------------ commit 2533decebb7fca65d2860174246966f5ed255dd0 Author: Paul E. McKenney <paulmck@xxxxxxxxxx> Date: Mon Oct 5 15:10:03 2020 -0700 datastruct/hash: Add missing hash_register_thread() The zoo_test() function was missing the hash_register_thread() invocation that is required to make hazard pointers work correctly. The lack of this invocation results in a segmentation violation. This commit therefore adds this call. Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx> diff --git a/CodeSamples/datastruct/hash/hashtorture.h b/CodeSamples/datastruct/hash/hashtorture.h index 6d30cb8..7d43e11 100644 --- a/CodeSamples/datastruct/hash/hashtorture.h +++ b/CodeSamples/datastruct/hash/hashtorture.h @@ -1211,6 +1211,7 @@ void zoo_test(void) for (i = 0; i < nupdaters * elperupdater; i++) { sprintf(&zoo_names[ZOO_NAMELEN * i], "a%ld", i); } + hash_register_thread(); zhep = malloc(sizeof(*zhep)); BUG_ON(!zhep);