[syslog-ng] Reference counter width of log messages and group/user handling
bazsi at balabit.hu
Wed Feb 13 20:13:31 CET 2008
On Wed, 2008-02-13 at 10:04 +0100, Roger J. Meier wrote:
> Hi all,
> These patches fix two segmentation fault and abort signal problems
> which we encountered in our use case of syslog-ng 2.0.8.
> Patch 1: "syslog-ng-2.0.8-refcounter.diff".
> If specifying more than about 256 "destination" directives inside one
> log directive, then the reference counter of a log message wraps.
> The reference counter width of LogMessage is expanded from 8 bit to
> unsigned int (32 bit). Reason: The reference counter wraps after 256
> increments, which causes an abort() call when decrementing the reference
> counter below 0 at a later time. The additional 3 bytes per message in
> memory seem to be affordable.
This one does not affect syslog-ng 2.1 OSE, that one uses 32 bits when
the SQL destination is enabled (threads are used, and atomic operations
require int), and 16 bits when not.
I'm trying to minimize LogMessage size as much as possible to minimize
cache usage, however some extra bytes still fit in.
32 bit mode:
syslog-ng 2.0: 104 bytes
syslog-ng 2.1 OSE: 116 bytes
syslog-ng 2.1 PE: 104 bytes
I guess in 64 bit mode it becomes more than two cachelines, not good.
I'm changing the refcounter to a 16 bit value, that'll permit about
65530 destination, is that enough for you?
I've committed this patch, it avoids a hole by increasing the "flags"
value as well.
@@ -77,8 +77,8 @@ void log_stamp_format(LogStamp *stamp, GString *target, gint ts_format, glong zo
typedef struct _LogMessage
- guint8 ref_cnt;
- guint8 flags;
+ guint16 ref_cnt;
+ guint16 flags;
/* meta information */
> Patch 2: "syslog-ng-2.0.8-group.diff".
> Handling of "-g" and "-u" options is not mutual exclusive: If group is
> specified on the command line, but not the user, then the user is a NULL
> pointer. Calling initgroups() with a null pointer segfaults in our
Right, this is true, I've applied and pushed this patch in the syslog-ng
2.1 branch. I'll backport this to 2.0 once I get there.
> And once again, many thanks to Bazsi for the syslog-ng software.
:) You are welcome.
More information about the syslog-ng