How to find "Range check error" quickly? lazarus / 12-Debugger ---------------------------------------------------------------------- stephanweber · 2019-06-24 10:37 Hi, in my Lazarus project I get this runtime error, because I have this check active in my proj options (-Cr). I have also set "Show debug info (-vd). However, how can I also get the code line in which this error happens, best wo. debugger. This is because currently I have not yet a debugger installed, and installations are always a bit difficult in my current Linux setup. In Delphi I remember something like "goto error" or "find error". Also with "Show line numbers" or "Show all procs on error" I get no more hints. The program recovers, because the error pops only up if I make an integer variable larger than 32K. But also changing the suspious variables to Int64 does not help. Bye Stephan ---------------------------------------------------------------------- devEric69 · 2019-06-24 10:52 If you know where is the line (say #num26) that throws this exception, one method might be to frame it like that, with a "defensive Exception management", just long enough to understand and correct you bug: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Try   your- buggy-line #num26 of code, hereExcept   on E: EOutOfRange do Application.processmessages; (* <-- you set a breakpoint there, and you'll inspect your numerical variables, i, strings[j], ..., which are used by your line #num26, and understand the one that exceeds its boundary.Once the bug will be fixed, you'll delete the try...except *)end; ---------------------------------------------------------------------- Martin_fr · 2019-06-24 11:10 -vd will not help at all You should include "debugger info" (preferably of type "dwarf"):  -gw You can add  -gl  then when your running executable hits the error, it should print a stacktrace with line numbers. (Run your app from a console, so you see the output / or try the "view" > "debug windows" > "console output") I am not sure what your problem is to install a debugger. GDB is usually easily available for linux. If your system is intel/amd based, then install the package LazDebuggerFp. This gives you a debugger that does NOT need gdb. ---------------------------------------------------------------------- stephanweber · 2019-06-25 13:13 Thanks. I found the problem with some statements like "Showmessage('here we are: begin of blablabla');" Now I have to find an infinite loop, which seems to be triggered randomly (there is indeed a random number generation involved). Bye Stephan ---------------------------------------------------------------------- Thaddy · 2019-06-26 08:12 If your two issues are related (as they seem to me) use RandomFrom or RandomRange instead of system.Random. Also, precisely define define a range as type ( e.g. type myrange i= 3..9 ). That combination will prevent you from making range errors at run-time. See: defensive programming in the wiki. https://wiki.freepascal.org/Defensive_programming_techniques (reminder to self: upload the rest, finally, lazy b*sta*rd) ---------------------------------------------------------------------- stephanweber · 2019-06-27 12:16 This was very helpful now: you should include "debugger info" (preferably of type "dwarf"):  -gw You can add  -gl  then when your running executable hits the error, it should print a stacktrace with line numbers. Run your app from a console!!! Thanks a lot!!