]> git.ipfire.org Git - thirdparty/squid.git/commit
Cover OnTerminate() calls unrelated to exception handling (#1430)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 16 Aug 2023 17:53:41 +0000 (17:53 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 16 Aug 2023 17:55:38 +0000 (17:55 +0000)
commitcf2fca525520630bfdb423793ccbbbfba5eba680
tree012625ea970ee9939bf772bba8c7286ea84c6118
parent3bd118d6c7951143612f304b8d2ada2b01633201
Cover OnTerminate() calls unrelated to exception handling (#1430)

The C++ standard lists many reasons[^1] for calling std::terminate().
All of them deal with an "exception handling failure". However, when
Squid bugs lead to an undefined behavior (e.g., by calling a pure
virtual function), some compilers also call std::terminate(). In those
cases, there may be no active exception, and our std::terminate()
handler's report about an "exception handling failure" (with "no active
exception") was confusing and misleading.

Also do not describe an exception when there is none. Callers that know
that the exception exists may continue to use CurrentException(),
especially if they do not need to report that exception on a dedicated
debugs() line. Other callers, including OnTerminate(), should use the
new CurrentExceptionExtra() manipulator.

[^1]: https://en.cppreference.com/w/cpp/error/terminate
src/base/TextException.cc
src/base/TextException.h
src/main.cc