Raising this issue on behalf of @hebasto who identified the potential problem as well as dug into the docs.
The logging
RPC method, through UpdateHTTPServerLogging()
calls the libevent function event_enable_debug_logging()
. The libevent documentation states that “You must make any changes to these settings before you call any other part of the Libevent library. If you don’t, Libevent could wind up in an inconsistent state.”, and the headers similarly state that “This is a global setting; if you are going to call it, you must call this before any calls that create an event-base. You must call it before any multithreaded use of Libevent.”
It was introduced in #10150, where reference is made to the libevent 2.1 release notes that state that “You can now turn on debug logs at runtime using a new function, event_enable_debug_logging().”, making this a seemingly safe implementation.
It appears that:
- Bitcoin Core’s usage of
event_enable_debug_logging()
violates the current libevent documentation - either there is inconsistency between the libevent 2.1 release notes and the documentation, or the behaviour of
event_enable_debug_logging()
has been changed after 2.1 in a backwards-incompatible way - this currently does not seem to be causing any real-world issues
Even though it seems like there are currently no actual problems, it’s probably something to be mindful of and ideally resolve, either by disabling toggling libevent debug logging at runtime or verifying that our current usage is indeed safe and will not lead to issues now or in the future.