[PATCH] New debug backend "ringbuf"

Volker Lendecke vl at samba.org
Sun Jan 8 09:48:26 UTC 2017


On Sun, Jan 08, 2017 at 10:08:53AM +0100, Ralph Böhme wrote:
> This one made my day when trying to fix a subtle bug in some asyc
> code in ctdbd_conn.c I'm currently working on. The bug was subject
> to timing effects, I could easily reproduce it at log level 1, but
> as soon as I cranked up log level it hid away. Arg.
> 
> I tried moving the logfile to a memdisk, but even with that, timings
> were different enough so I still couldn't reproduce it. Ahhhhhh...
> 
> That's when I thought of adding a new logging backend that simply
> writes all log messages into a memory buffer, et voila, with this I
> was able to reproduce the issue at log level 10. Bug found and
> fixed. :)
> 
> To make use of it when hunting for a bug, you must be able to
> identify a place in the codepath where you know things are gone
> south and you can cause a panic. You then attach with gdb to the
> panicked (and in developer mode sleeping process, otherwise grab the
> corefile) and run:
> 
> (gdb) dump binary memory samba.log debug_ringbuf debug_ringbuf+SIZE
> 
> The default size is 1 MB, but this can be changed by a backend
> option:
> 
>  logging = ringbuf:size=NBYTES
> 
> Fwiw, the ringbuffer is of course only allocated if the backend is
> used.

This looks really interesting. Question -- would you be fine if I
wrote a smbcontrol to grab the log, similar to for example pool-usage?

Volker



More information about the samba-technical mailing list