Bug 702217

Summary: glib g_timeout_add integer overflow [syslog-ng stats_freq option not interpreted correctly]
Product: [openSUSE] openSUSE 11.4 Reporter: Forgotten User 2Xrp_Q7k_A <forgotten_2Xrp_Q7k_A>
Component: BasesystemAssignee: E-mail List <gnome-bugs>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: bazsi, mt, peter
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 11.4   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Forgotten User 2Xrp_Q7k_A 2011-06-26 12:32:03 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.19) Gecko/20110420 SUSE/2.0.14-4.1 SeaMonkey/2.0.14

syslog-ng 3.2.2-5.1: When one uses the option

   stats_freq(60140);

a statistics log record should be output roughly every week. Instead it's output every 10 seconds. That number 10 depends on 60140, if I change the latter, the former changes accordingly.

Reproducible: Always

Steps to Reproduce:
1. Add option stats_freq(60140); to syslog-ng.conf
2. Restart syslog-ng.
3. Wait 10 seconds. :-)
Actual Results:  
Statistics log message is output every 10 seconds.

Expected Results:  
Statistics log message should be output every 60140 seconds.

60140 seconds is, of course, a contrived example. I wanted weekly stats records (i.e., every 60480 seconds). But then you have to wait ca. 6 minutes for the superfluous log records. ;-)
Comment 1 peter czanik 2011-06-27 19:33:48 UTC
Tested it and confirmed. Forwarded the bugs to upstream developers.
CzP
Comment 2 Balázs Scheidler 2011-07-01 14:44:53 UTC
Hmm... I couldn't reproduce it with the latest syslog-ng 3.2 git tree, however
I can't remember any fixes in the area.

Are you sure you wrote the correct number of digits in the error report? I mean one week is 24*60*60*7 = 604800 and not 60480 (one digit less).

This number is multiplied by 1000 to get msec instead of seconds, but that still
gits into the 32 bit integer it is stored in. (around 600 million, but we're ok
until about 2 billion). The glib version can matter too, in my build environment
I use 2.14.6, yours is probably newer. This might also be a factor. (for instance if glib uses nanoseconds internally, that would already overflow)

But anyway, I'd suggest to use shorter timeouts, is one per day so much extra
traffic? This way you can check message drops etc

So I wouldn't want to fix this upstream, especially as syslog-ng 3.3 is using
a completely different event library (ivykis instead of glib).
Comment 3 peter czanik 2011-07-01 15:13:47 UTC
Yes, it is 60480 which gives stat in every ten seconds.

Just tested 3.2.4 on factory, and that does not seem to be affected. Obviously many other packages were updated too.

I'll try to compile 3.2.4 for openSUSE 11.4 and give it a try.
Comment 4 Marius Tomaschewski 2012-02-28 10:03:47 UTC
This is a glib integer overflow and fix for this issue is in
commit c2fbef4125977d0c1aa1a9859491e694c9c71b05.

See also:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=606618
https://bugzilla.gnome.org/show_bug.cgi?id=642052

I think it makes sense to fix it in glib2.
Comment 5 Marius Tomaschewski 2012-02-28 10:13:11 UTC
BTW: the bug can be reproduced with g_timeout_add_seconds, too.
Comment 6 Marius Tomaschewski 2012-02-28 10:32:55 UTC
BTW:
A 60130 causes to execute the timer function every second, that is with
default config 78MB / day. But 60129 does not execute it at all, that is
there seems to be a >0 check inside of glib.
Comment 7 Vincent Untz 2012-02-28 10:46:26 UTC
Link to the patch: http://git.gnome.org/browse/glib/patch/?id=c2fbef4125977d0c1aa1a9859491e694c9c71b05

Can someone confirm that the patch fixes the issue? Or do you need me to produce a test package?
Comment 8 Marius Tomaschewski 2012-02-28 11:53:44 UTC
Vincent,

can you create a branch $yourhome:branches:openSUSE:11.4:Update:Test/glib,
apply it and let me know the name please? I'll use it as repo to build
a syslog-ng package and then we can test it.
Comment 9 Marius Tomaschewski 2012-02-28 12:08:17 UTC
Ahm... 
ldd /sbin/syslog-ng says, that on 11.4 glib2 is in /lib64/libglib-2.0.so.0
already, syslog-ng is not linked statically any more, so I don't even need
to rebuild syslog-ng. So we just need a fixed glib package to test it.
Comment 10 Vincent Untz 2012-03-02 08:44:37 UTC
Test package available in home:vuntz:branches:openSUSE:11.4:Update:Test/glib2.
Comment 11 Tomáš Chvátal 2017-08-12 08:59:37 UTC
Fixed in follow-up releases and 11.4 is out of support.