]> git.ipfire.org Git - thirdparty/squid.git/commit
Do not erase aborted StoreMap entries that are still being read (#1344)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 17 May 2023 19:33:51 +0000 (19:33 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 18 May 2023 05:29:56 +0000 (05:29 +0000)
commit9a854a62c3a3b934a4f4b755c4f3305d77a0201b
tree35fcdfd3bd8e1d193151eb43a413121b265796dd
parentdbedb5b909bbd9bad7af040d73e64f5ca43ce0c8
Do not erase aborted StoreMap entries that are still being read (#1344)

The old `!s.lock.readers` precondition for calling freeChain() in
StoreMap::abortWriting() was not broad enough: It covered "old" readers
that have incremented ReadWriteLock::readers already while missing those
lockShared() callers that have fully qualified for becoming a reader but
have not incremented the `readers` counter yet. A correct test is now
implemented by ReadWriteLock::stopAppendingAndRestoreExclusive().

This code was broken since appending mode was introduced in 2013 commit
ce49546. Evidently, the mishandled race condition is short-lived enough
and abortWriting() calls are rare enough, that there are no (known)
relevant bug reports. This bug was accidentally discovered while reading
the code to explain another SMP bug.

Controller::markedForDeletionAndAbandoned() similarly misjudges
readers(), but that bug does not lead to serious problems, and we would
like to find a fix that identifies such entries without false positives
(that looking at ReadWriteLock::readLevel instead of readers creates).

Also polished Ipc::StoreMap::abortWriting() debugging a little.
src/ipc/ReadWriteLock.cc
src/ipc/ReadWriteLock.h
src/ipc/StoreMap.cc