]> git.ipfire.org Git - thirdparty/squid.git/commit
Keep ::helper objects alive while in use by helper_servers (#1389)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Mon, 14 Aug 2023 01:39:29 +0000 (01:39 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 15 Aug 2023 20:40:11 +0000 (20:40 +0000)
commit3bd118d6c7951143612f304b8d2ada2b01633201
tree432ea3354f498d2e694b3e638f4bbe721cc912bf
parent6240f5809146d3b6dcfcfd7b40e14c70ecb9af9a
Keep ::helper objects alive while in use by helper_servers (#1389)

Squid creates ::helper objects to manage a given configured helper. For
each ::helper object, Squid may create one or more helper_server objects
to manage communication with individual helper processes. A
helper_server object uses its so called "parent" ::helper object to
access configuration and for helper process death notification purposes.
There are no checks that the "parent" object is still alive when used.

The same problem applies to statefulhelper and helper_stateful_server.

helper_server code evidently attempted to extend their "parent" lifetime
using cbdata, but that does not work, especially in C++ world where the
object is destructed (and, hence, enters an undefined state) even though
its top-level memory is preserved by cbdata. Non-trivial members like
helper::queue (std::queue) and statefulhelper::reservations
(std::unordered_map) release their internal memory when destructed.

We now refcount ::helper objects to keep them alive until the last
object using them is gone. This does not result in reference loops
because the ::helper object uses raw dlink_node pointers to store its
helper_servers.

The following helpers (listed here by their container names) were
destructed while possibly still in use by their helper_server objects:
external_acl::theHelper, Ssl::CertValidationHelper::ssl_crt_validator,
Ssl::Helper::ssl_crtd. The following helpers are not destructed during
reconfiguration: redirectors, storeIds, basicauthenticators,
ntlmauthenticators, negotiateauthenticators, and digestauthenticators
(even though casual reading of relevant code may suggest otherwise).

This bug fix does not address or mark many remaining helper bugs.
16 files changed:
src/auth/basic/Config.cc
src/auth/basic/Config.h
src/auth/digest/Config.cc
src/auth/digest/Config.h
src/auth/negotiate/Config.cc
src/auth/negotiate/Config.h
src/auth/ntlm/Config.cc
src/auth/ntlm/Config.h
src/external_acl.cc
src/helper.cc
src/helper.h
src/helper/forward.h
src/redirect.cc
src/ssl/helper.cc
src/ssl/helper.h
src/tests/stub_helper.cc