PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Finding a Null pointer or Array out of Bounds in FreeBASIC  (Read 535 times)

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8118
  • Windows 10
    • PlanetSquires Software
Finding a Null pointer or Array out of Bounds in FreeBASIC
« on: March 03, 2017, 08:29:22 PM »

Did you ever have that one problem that you just couldn't find in your code? That elusive GPF that you know for sure has to be caused by a null pointer or array out of bounds error. Well, I did, and it was driving me nuts. In the end it was just a very simple fix but finding it became an exercise of trying to find a needle in a haystack. Very frustrating. I turned to FB's built in functionality for creating debug files and error checking for help.

Using WinFBE, i set my project to compile using the -exx and -g options.

Copied GDB.exe (the debugger found in \bin\win32) to the same folder as my project's exe. Also needed to copy a couple of support files (zlib1.dll and libgcc_s_dw2-1.dll).

Dropped down to a command window into the same folder as the project's exe and the debugger.

Typed:   gdb.exe winfbe32.exe     (obviously you would use your program's exe name)

Executed the program by typing "r" to start the application.

Used the program as normal until the GPF occured. Then, checked the output window and sure enough I was given an excellent error message that told me exactly the file and line number where the GPF originated. Fixed the problem in 10 seconds after that.

Check out the topic called "Debugging with FreeBASIC" in the FB help file.

Saved me a lot of time.  :)






Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor