I've been debugging the logging valgrind issues this morning and it seems to be a more general issue than just the logging code. The leak comes from *log_openfile's use of *wt_scr_alloc when called from *wt_logmgr_create. That code correctly calls *wt_scr_free, but __wt_scr_discard is never called.
The underlying issue is that the server threads are handled in *wt_connection_open, and that is called before the connection's session is opened, and conn->session is, at that time, set to dummy_session. The leak happens because the scratch buffers are allocated in the dummy session, and the *wt_connection_close code does not call session->close on the dummy_session. So resources allocated in the context of the dummy session are not closed/discarded/freed.
Logging is not the only startup code that could be affected by this. __ckpt_server_config also uses a scratch buffer but none of the sample programs that valgrind runs configures checkpoints in a way to trigger it. But if they did, that should show up too.
I'm going to mull over various solutions.
-