5 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding · 1 suggestion. See the Run archive for their assessments.
Optional improvements
[suggestion] · Callback contract still excludes the motivating finalizer case
Finalizer-driven kernel calls remain forbidden, while same-thread callback re-entry is undocumented and requires more than thread safety if that use is intended to work.
Location: src/kernel/bitcoinkernel.h:411 (head).
Details and suggested fix
KernelLogger::Log() now unlocks before invoking user code and has no per-thread recursion guard. If a finalizer run during the callback calls a kernel destructor that logs an accepted entry, Log() invokes the same callback recursively on that thread. A callback protected by a non-recursive lock can then deadlock despite being thread-safe. Clarify whether this motivating case is supported: the C header still forbids all kernel API calls except entry getters, and the wrapper mentions only thread safety. If finalizer-driven calls are intended to work, document same-thread re-entry and the need not to hold non-recursive locks across work that may log. Explicitly keep destruction of the connection itself forbidden: UnregisterCallback() waits for the current invocation too, so it cannot complete from inside that callback. This self-deadlock pre-exists the PR. Otherwise, retain the prohibition and narrow the motivating claim. No in-tree binding that runs finalizers on the callback thread was identified, so production impact remains unconfirmed.
[suggestion] · Concurrency test hangs instead of reporting serialized callbacks
If callbacks become serialized again or the signet Info entry stops being emitted, the test cannot reach its assertions or cleanup and relies on an outer timeout.
Location: src/test/kernel/test_kernel.cpp:810 (head).
Details and suggested fix
Each BlockingLog::LogMessage() increments entered and then waits for released, but the main thread sets released only after both callbacks enter. With serialized callbacks, the first invocation blocks at the serialization point and the second never increments entered. If the Info entry disappears, neither invocation enters. The CMake registration supplies no local timeout, so CI eventually reports a CTest timeout rather than a focused assertion failure. Replace the rendezvous with a bounded wait and capture whether both callbacks entered before cleanup. On timeout, set and notify released, join the logging threads, and then fail the captured check. Recording the result before release prevents callbacks entering during cleanup from turning a timeout into a pass.
[suggestion] · Teardown coverage misses the last running callback
The test releases both callbacks together, so it can miss destruction of user_data after only one invocation returns.
Location: src/test/kernel/test_kernel.cpp:818 (head).
Details and suggested fix
Both invocations wait on the same released flag. Before release, BOOST_CHECK(!destroyed) follows a 100 ms sleep that does not establish whether the destroyer has reached teardown. After release, the test checks destruction only after every join. A teardown that returns after the first invocation finishes could therefore pass under a suitable schedule, despite violating the documented lifetime guarantee. Give the callbacks separate release gates and have the destroyer signal immediately before logger.reset(). Wait for that signal before the timed negative check, then release and join one logging thread and check that user_data remains alive while the other callback is blocked. Finally release the second callback and join the destroyer.
[suggestion] · A single std::cout insertion does not guarantee whole log lines
Formatting each line first reduces interleaving but does not portably prevent it in the demo and test loggers, contrary to their comments.
Location: src/bitcoin-chainstate.cpp:57 (head).
Details and suggested fix
Releasing the kernel mutex before the callback allows concurrent invocations of each writer. Synchronized standard streams avoid data races, but C++ does not guarantee that one operator<< inserts all characters indivisibly. Common standard libraries may serialize this insertion, and no interleaving on a supported platform is established here. To guarantee that concurrent log-callback writes do not mix, protect the final insertion in both KernelLog and TestLog with a function-local static mutex, leaving line formatting outside the lock. This serializes the sink rather than the kernel callback path. Otherwise, narrow the comments to say that the change reduces interleaving.
[suggestion] · Above-Info filtering is untested through the connection setter
The new connection setter is tested only with DEBUG_LEVEL, so filtering of unconditional Info entries is untested.
Location: src/test/kernel/test_kernel.cpp:749 (head).
Details and suggested fix
The Info deliveries in logging_connection_tests all use the default threshold, and the only tested setter argument is DEBUG_LEVEL. LogInfo is unconditional, so KernelLogger::Log() must filter it when the connection's minimum exceeds Info. A setter that always stored Debug would still satisfy the current logging assertions. Extend this test using its existing log_info() helper: set WARNING_LEVEL, emit the signet Info entry, and assert that no message was delivered. Then set INFO_LEVEL, emit again, and assert exactly one delivery.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Expose the log entry's rate-limit hint
- [minor]: Keep registration unavailable until old user data is destroyed