Range Check error - works fine after reboot lazarus / 1-Linux ---------------------------------------------------------------------- TheMouseAUS · 2023-12-19 21:47 I have an application I made which runs 24/7 after a few weeks i get the error message 'Rage Check Error'. I close the app and start it again but the error comes up before the form is even drawn on the screen. A reboot of the PC and with works perfectly fine again. What is the best way of diagnosing/debugging this issue? The PC is running Fedora 38 Plasma - QT5 Complied on Lazarus 2.2.6/ FPC 3.2.2 Fedora 38 X64 QT5 ---------------------------------------------------------------------- Bart · 2023-12-19 23:00 Build with -Cr (range checks enabled) and -gl, sou you get a linenumber information in the stacktrace. Bart ---------------------------------------------------------------------- paweld · 2023-12-20 08:40 According to what you write, it seems to me that somewhere in the code you use GetTickCount - that is, the problem starts after 24 days and 20.5 49 days and 17 hours (corrected after Thaddy's post). Restarting the computer helps because the counter then starts from 0. Replace GetTickCount with GetTickCount64 and if you are writing the result to a variable then change its type to Int64 QWord - this should solve the problem. ---------------------------------------------------------------------- Thaddy · 2023-12-20 12:59 That is indeed the correct answer, Pawel, except it wraps every 49,7 days since its value is unsigned. And this has been a very old problem and every programmer could have known this. The issue is not even related to Freepascal but initially related to the Windows API. It is also documented in the FPC manuals. GetTickCount returns a cardinal GetTickCount64 returns a Qword Never use a signed integer type for either version. ---------------------------------------------------------------------- paweld · 2023-12-20 14:07 Quote from: Thaddyexcept it wraps every 49,7 days since its value is unsigned. My bad. Corrected ---------------------------------------------------------------------- Thaddy · 2023-12-20 14:56 Quote from: paweld on December 20, 2023, 03:07:42 pmQuote from: Thaddyexcept it wraps every 49,7 days since its value is unsigned. My bad. Corrected Once it was also my bad, back in my PerfectView days in 1996: So the problem is a permanently recurring one... :'( ---------------------------------------------------------------------- TheMouseAUS · 2023-12-20 19:25 Awesome thanks now that makes sense, yes I am indeed using tickcount64 and I was storing the value as an integer. I have corrected that to a QWord. I was trying to measure the time in ms for network communication between two devices. Is there a better way? Anyway thank you so much, I knew someone would know my stuff up I am still learning :-)