Mysterious problem.

General FreeBASIC programming questions.
Post Reply
Peter_G
Posts: 16
Joined: May 16, 2006 19:45
Location: Hertfordshire, UK

Mysterious problem.

Post by Peter_G »

I am in the process of writing and debugging a fairly complex programme to solve (or help to solve) a 9 x 9 Sudoku puzzle for a bit of fun. The programme runs as a state machine and one specific state causes a programme crash every time when executed - but only if run by the state machine.
If the same code (minus it's "if state = xx then" and "end if" ) is run continuosly in a loop there is no obvious problem and the code executes correctly as programmed. The "crash" can be pinpointed, I think, to a return from a deeply embedded subroutine by stepping though the code with print statements tracking progress and it generates the following crash report.

Problem signature:
Problem Event Name: APPCRASH
Application Name: FBIDETEMP.exe
Application Version: 0.0.0.0
Application Timestamp: 6686afee
Fault Module Name: FBIDETEMP.exe
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 6686afee
Exception Code: c0000005
Exception Offset: 00000000000024bf
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 2057
Additional Information 1: 641b
Additional Information 2: 641be5a47be374c30ef0a1c17aa26819
Additional Information 3: 3d49
Additional Information 4: 3d494201d607379df9256a28a9503a88

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid= ... cid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt

I'm happy to pass over the errant .bas file if that might be of assistance, but are there any clues as to my error in the above report before taking the problem to the next - very much more complicated level.

I would be very grateful for assistance in tracking down this problem.
fxm
Moderator
Posts: 12403
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Mysterious problem.

Post by fxm »

Compile the program with the '-exx' option and check if a runtime error message appears on the text console output.
Peter_G
Posts: 16
Joined: May 16, 2006 19:45
Location: Hertfordshire, UK

Re: Mysterious problem.

Post by Peter_G »

Thanks fxm

With the above change, the console output appeared very briefly - there was some text but I was unable to read it in time.
fxm
Moderator
Posts: 12403
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Mysterious problem.

Post by fxm »

As you are using FBIde, see here to configure FBIde to keep the text console open (and therefore see the runtime error messages).
Specially see the 'Leaving the command line window open when the program finishes' paragraph.
Peter_G
Posts: 16
Joined: May 16, 2006 19:45
Location: Hertfordshire, UK

Re: Mysterious problem.

Post by Peter_G »

OK - did that and now have message in window - " Runtime error 6 (out of bounds array access) at "get_mouse" line484. This refers to line marked with *********************** below.

Obviously needs investigating!!!!! Thanks for the assistance - just hope my home brewed mouse routine can be rectified

I'll report back if something is found, although the routine seems to work faultlessly whenever I have required its use.

Code: Select all

sub get_mouse()
    getMouse (mx, my, mz, but)
    if  mx = -1 and my = -1 and but = -1 And mz = -1 then
        mx = old_mx : my = old_my : mz = old_mz : but = old_but
    end if

    if  old_but = 0 and but > 0 then mbutts(but) = 1      '  Pressed 
    if  old_but > 0 and but > 0 then mbutts(but) = 3      '  Held 
    if  old_but > 0 and but = 0 then mbutts(but) = 7      '  Released
    if  but_act = 0 and mbutts(but) = 7 then but_act = old_but             ' "0" if action completed ******************************!!!
'    
    if  mz - old_mz > 0 then scroll += 1
    if  old_mz - mz > 0 then scroll -= 1
'
    old_mx = mx : old_my = my : old_mz = mz : old_but = but                ' Save before exit
    locate 62,116:? "action";but_act;" ";mbutts(1);" ";mbutts(2);" ";mbutts(4);        ' Show whar's happening  TEST!!!
end sub
fxm
Moderator
Posts: 12403
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Mysterious problem.

Post by fxm »

As 'but' can vary from 0 to 7 (all mouse buttons pressed), the 'mbutts()' array must be defined accordingly (from index 0 to index 7).
But maybe this bug is not responsible for your crash, and there are still other problems after this one !
Fix this runtime error and repeat the same test (always with the '-exx' option).
Peter_G
Posts: 16
Joined: May 16, 2006 19:45
Location: Hertfordshire, UK

Re: Mysterious problem.

Post by Peter_G »

Thanks for that revealing comment!! I checked the declaration of that array and found it was :-

" Dim shared as ubyte mbutts(1 to 4) ' Mouse button action history " !!! Silly error!!

Changed it to
" Dim shared as ubyte mbutts(0 to 7) ' Mouse button action history" - problem solved, sanity restored!!

Thanks again for your assistance - much appreciated.
Post Reply