ITimer::getReadlTime() EPIC BUG

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

ITimer::getReadlTime() EPIC BUG

Post by devsh »

So we at Build A World have discovered a bug in Irrlicht that has most probably been there since the dawn of time.

Namely irrlicht is returning system time in milliseconds as the RealTime, however it is doing that in the u32 format.

U32 is ONLY sufficient for real time (time since the start of 1970) if you are counting in SECONDS.

If you wish to return MILISECONDS, then you need to use int64_t or uint64_t because otherwise you run out of precision by March 1970.

And if you have for example, a server app... which has almost 99% uptime... then you are sure to run into an integer overflow (on a certain date at a certain time every 49 days) and a crash or bug which is timing related.

Please change your timer data type to 64bit int, I do not care if its signed or unsigned
sodandk
Competition winner
Posts: 340
Joined: Wed Aug 10, 2011 11:58 am

Re: ITimer::getReadlTime() EPIC BUG

Post by sodandk »

again... looking for a bug in baw, which wasn't there... was in fundaments of irr :-(
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ITimer::getReadlTime() EPIC BUG

Post by CuteAlien »

Funny what counts as epic these days. Interface shows it's just using 32-bit which is exactly what it does.
Using 64-bit for this means we are starting to lie on systems where only a 32-bit counter is used (which is used when users don't request a high-performance counter for example).

edit: I'll put it on my todo. Maybe we can use 32-bit counters with wrap-around checks and counting the wrap-arounds. As long as tick is called once very few days that would work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: ITimer::getReadlTime() EPIC BUG

Post by devsh »

yeah but the 32bit counter gets multiplied by 1000 to convert seconds to miliseconds
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: ITimer::getReadlTime() EPIC BUG

Post by Nadro »

Yes, Irrlicht timer isn't good choice (in my personal projects I use custom timer) mainly on mobiles (often sync a timer via network), because it use "gettimeofday" function inside ITimer class. We should use "clock_gettime" with "CLOCK_MONOTONIC". I'll fix that in upcoming days (currently I work with my tasks required for merge ogl-es with trunk, but I should find some time for replace "gettimeofday" by "clock_gettime" + "CLOCK_MONOTONIC").
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ITimer::getReadlTime() EPIC BUG

Post by CuteAlien »

Not familiar with that one... monotonic sounds a little bit like getTickCount on Windows from the description. Are you sure that's a high-resolution timer?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: ITimer::getReadlTime() EPIC BUG

Post by Nadro »

This is nice article about timers:
http://tdistler.com/2010/06/27/high-per ... ux-windows

When I started to use CLOCK_MONOTONIC my games on Linux and Android works much better than before.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ITimer::getReadlTime() EPIC BUG

Post by CuteAlien »

Thanks, sounds good then.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply