]> git.ipfire.org Git - thirdparty/bird.git/commit
Fixed a bug in hot page global storage
authorMaria Matejka <mq@ucw.cz>
Fri, 5 May 2023 07:39:13 +0000 (09:39 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 6 May 2023 08:50:32 +0000 (10:50 +0200)
commita95141111c89803347c36501185a76fc73a9764a
treea96a54914cf2498d02546ed49f8e2b852680229b
parent00f30ac40bda76b289b1dc5c5aa8a5d2e4941985
Fixed a bug in hot page global storage

The original algorithm was suffering from an ABA race condition:

A: fp = page_stack
B: completely allocates the same page and writes into it some data
A: unsuspecting, loads (invalid) next = fp->next
B: finishes working with the page and returns it back to page_stack
A: compare-exchange page_stack: fp => next succeeds and writes garbage
to page_stack

Fixed this by using an implicit spinlock in hot page allocator.
lib/birdlib.h
sysdep/unix/Makefile
sysdep/unix/alloc.c
sysdep/unix/alloc_test.c [new file with mode: 0644]
sysdep/unix/log.c