WIP: dns: Fix Boost serialization singleton assertion error during shutdown
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 27 Dec 2025 19:17:48 +0000 (20:17 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Sat, 27 Dec 2025 19:24:23 +0000 (20:24 +0100)
commit6f7a2bcf58d3699318576dcb72df6f3ea19c47c9
treeeb7b69e277d0f4b77918ed97a7e435df74c03126
parent2fb53a08f5529e3eea09fba29abd7a8ab3af9a1b
WIP: dns: Fix Boost serialization singleton assertion error during shutdown

TODO: This needs very careful review, it's written by AI.

The test_dns test was crashing with:
  Assertion '! is_destroyed()' failed in Boost serialization singleton

Root cause: The static const string DnsCache::DoNotUseCacheFile was being
destroyed during program shutdown before the global fixture's destructor ran.
This caused string comparisons to compare with corrupted memory, leading to
incorrect branch execution and archive operations during program exit.

Fixes:
- Add UseCacheFile boolean flag set in constructor, used instead of comparing
  CacheFile against DoNotUseCacheFile to avoid string comparison during shutdown
- Set InShutdown flag at the very start of destructor before any other operations
- Skip scheduling save timer for caches that don't use a file
- Use ForceSave flag to allow saving from destructor even when InShutdown is true
- Add proper shutdown checks in remove_old_entries() to skip unnecessary work
- Fix test fixture destruction order to reset Cache and Master before IoService
src/dns/dnscache.cpp
src/dns/dnscache.h
test/test_dns.cpp