Repository navigation
Keep thread names longer than 15 characters on macOS - #1008
Merged
odygrd merged 1 commit intoOct 24, 2026
Merged
Conversation
get_thread_name() read the calling thread's name into a 16-byte buffer on every non-Windows platform. 16 bytes is the Linux limit, but macOS keeps thread names of up to 63 bytes and pthread_getname_np() only copies what fits in the supplied buffer, so %(thread_name) showed only the first 15 characters of longer names. Size the buffer for 64 bytes instead. Linux still returns at most 15 characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
detail::get_thread_name()reads the calling thread's name into a 16-byte buffer on every non-Windows platform (include/quill/backend/ThreadUtilities.h). 16 bytes is the Linux limit, but macOS keeps thread names of up to 63 bytes, andpthread_getname_np()only copies what fits in the buffer it is given. The name is read once per thread and cached, so%(thread_name), and thethread_namepassed to sinks and filters, only ever shows the first 15 characters of a longer name. The Windows branch already reads up to 256 characters.A thread named
network-receiver-thread-01logging with the pattern[%(thread_name)] %(message):The fix sizes the buffer for 64 bytes (
MAXTHREADNAMESIZEon macOS) and passessizeof(thread_name)instead of the hard-coded 16. Linux caps thread names at 15 characters, so the result there is unchanged. The FreeBSD/OpenBSD branch reads into the same buffer; I could only verify on macOS.The new
get_thread_name_returns_names_longer_than_15_charactersunit test names the current thread withset_thread_name()and checks thatget_thread_name()returns the full name. It runs on macOS and returns early elsewhere, like the Linux-onlyset_thread_name_validates_lengthtest next to it. I added anUnreleasedchangelog entry.Verified on macOS arm64 with Apple clang 21:
cmake -S . -B build -G Ninja -DQUILL_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug, thencmake --build build --target TEST_BackendUtilities.REQUIRE_EQ( quill-thread-na, quill-thread-name-longer-than-15 ). With the change it passes.ctestrun after rebuilding all test targets: 437 of 446 pass. The 9 failures are the backend lock-file tests and the stdout/stderr capture tests, which need to create files directly in/tmp. My build environment blocks that, and the same 9 fail on master.🤖 Generated with Claude Code