Skip to content

Logging: improve suppression thread safety; fix file/line logging in gamelogic - #1829

Merged
slipher merged 4 commits into
DaemonEngine:masterfrom
slipher:logging-fixes
Oct 5, 2025
Merged

slipher merged 4 commits into
DaemonEngine:masterfrom
slipher:logging-fixes

Conversation

@slipher

@slipher slipher commented Sep 29, 2025 •

Copy link
Copy Markdown
Member

In the engine, access the logs.suppression.* cvars through their objects, instead of looking them up in the cvar map via their names. Looking them up via name is seriously unsafe on a non-main thread. Simply reading the int or bool is still technically thread-unsafe, but should be fine in practice.

Fix logs.writeSrcLocation.* access in gamelogic. These cvars will no longer emit warnings due to duplicate registration, and be obeyed by the gamelogic.

In the engine, access the logs.suppression.* cvars through their objects,
instead of looking them up in the cvar map via their names. Looking them
up via name is seriously unsafe on a non-main thread. Simply reading
the int or bool is still technically thread-unsafe, but should be fine
in practice.

The gamelogic still has to look up cvars by name, but there is no issue
because logging is prohibited on non-main threads.

Fixes, for practical purposes,
DaemonEngine/Daemon-vulkan#21.
logs.writeSrcLocation.* cvars no longer emit warnings due to
duplicate registration, and are obeyed by the gamelogic.
@slipher
slipher merged commit 18f5c57 into DaemonEngine:master Oct 5, 2025
9 checks passed
@slipher
slipher deleted the logging-fixes branch October 5, 2025 15:46
@illwieckz

Copy link
Copy Markdown
Member

@slipher I now get this linkage error:

[100%] Linking CXX executable daemon
/usr/bin/ld: CMakeFiles/client-objects.dir/src/engine/qcommon/msg.cpp.o: in function `Cvar::Cvar<bool>::Get() const':
src/common/Cvar.h:278:(.text._ZN3Log14AddSrcLocationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcS9_ib[_ZN3Log14AddSrcLocationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcS9_ib]+0x32):
 undefined reference to `Log::logExtendAll'
/usr/bin/ld: src/common/Cvar.h:278:(.text._ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_[_ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_]+0x83):
 undefined reference to `Log::logExtendNotice'
/usr/bin/ld: CMakeFiles/client-objects.dir/src/engine/qcommon/msg.cpp.o: in function `void Log::Logger::NoticeExt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int&>(char const*, char const*, int, Str::BasicStringRef<char>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int&)':
src/common/Log.h:228:(.text._ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_[_ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_]+0x396):
 undefined reference to `Log::Logger::Prefix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
/usr/bin/ld: src/common/Log.h:228:(.text._ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_[_ZN3Log6Logger9NoticeExtIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERiEEEvPKcSB_iN3Str14BasicStringRefIcEEDpOT_]+0x3d0):
 undefined reference to `Log::Logger::Dispatch(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Log::Level, Str::BasicStringRef<char>)'

@illwieckz

Copy link
Copy Markdown
Member

Ah no it's a false alarm. That's one of the very rare case where CMake fails to properly invalidate the targets and fails at rebuilding the executable. Deleting the build folder fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants