Runs in Debug but not in Release

BlitzMax Forums/BlitzMax Beginners Area/Runs in Debug but not in Release

Eric(Posted 2006) [#1]
Does anyone know what could cause a program to run perfectly well in debug mode but not in Release mode.


tonyg(Posted 2006) [#2]
What happens in release mode?


Eric(Posted 2006) [#3]
Well... It's hard to say really... The program executes, the screen goes blank and I can't get out of the program. So I have to reboot.

In debug mode...It runs as expected.


Perturbatio(Posted 2006) [#4]
Try rebuilding all your modules to ensure the release versions are up to date.


Eric(Posted 2006) [#5]
I did that and nothing changed.

I usually use debug mode.. My program is getting faily long now, andI have no Idea what the difference is between debug and release, besides the obvious.


xlsior(Posted 2006) [#6]
In windowed, or full-screen mode?

(If fullscreen, try switching to windowed mode and see if the screen remains blank)


Chris C(Posted 2006) [#7]
try changing to superstrict that could help


Eric(Posted 2006) [#8]
OK I will try windowed mode when I get home tonight, The program is in full screen. Now if it works in windowed mode what then? I have updated all of my drivers.

Chris, Since the advent of Super Strict I always us it.


Chris C(Posted 2006) [#9]
LOL - good init!

do let us know if you find the problem!


Eric(Posted 2006) [#10]
Well, nothing I have tried works... I guess I am going to have to remove lines of code (ugg!) in order to find out what is causing this problem.

I've tried this on both of my computers and both show a blank screen in release mode. Debug is perfectly fine.

Eric


Beaker(Posted 2006) [#11]
You can Print to the console to try and locate where it goes wrong.

Also, might be worth trying the GL driver (if you are on Windows).


Chris C(Posted 2006) [#12]
I had a similar problem using a C library (as it turned out it was an uninitialised variable in the C part

To trace it ended up putting
print "1"
print "2"
etc at many point in the program!

you many also want to print out any variables to see if they have sane values

are you using any external libs?


Eric(Posted 2006) [#13]
I Isolated is to this.
	Method Closest:TObject(Item:TCollection)
		Local TestRange:Float=10000
		Local Range:Float 
	 	Local Swap:Byte
		Repeat
			Swap=False 
			For Local Index:TObject=EachIn Item:TCollection
			 	Range=Position.DistanceTo(Index.Position)
				If Range<TestRange
					TestRange=Range
					Attack=Index
					Swap=True
				End If
				'Print "Range "+Range
			Next
		Until Swap=False Or KeyHit(Key_Escape)
		Return Attack
	End Method 


In debug it runs great. Now if I am in Release mode, and I uncomment the 'Print "Range "+Range" ' Line It runs.. it's very jumpy because of the statement. But why would this one line change the program.


skidracer(Posted 2006) [#14]
Thats an interesting problem and I think I know what's happening and can probably reproduce it.

In the meantime, does "If Range*1.0001<TestRange" fix it?


Eric(Posted 2006) [#15]
Yes that worked...What is causing that?

Thanks...Can this be fixed in a normal Module Sync?


Floyd(Posted 2006) [#16]
I have a vague notion of what's happening.

The problem is that you can't control the precision used for calculations. A float (32-bit) is actually 64-bit or 80-bit when held in a register. The value drops back to 32-bit when stored in memory.

Debug and Release differ in this register handling. And Printing a value can force it to be temporarily stored in memory, thus changing the precision.

I don't know exactly what's happening in your program, but this is probably the underlying cause of the trouble.


Eric(Posted 2006) [#17]
Skidracer,

Is there going to be a fix for this?

Eric


TomToad(Posted 2006) [#18]
Possibly use Double instead of float?


Eric(Posted 2006) [#19]
Nope that did not work...Good thought though. :)


skidracer(Posted 2006) [#20]
a little more concise:
Function mynumber##()
	Return Sqr(2.0)
End Function

Local a#=mynumber()

If a>mynumber() Print "no @#!*ing way"

End


changing the function to return a float interestingly fixes it so not sure there is any problem here...


Eric(Posted 2006) [#21]
But it still doesn't fix my problem.

I changed all Floats to doubles.

Range=Position.DistanceTo(Index.Position)


The Method .DistanceTo Returns A double.

And my above sample works when I use your original suggestion. But I can't get it to work otherwise.


skidracer(Posted 2006) [#22]
It's certainly kept Mark quiet for the last 30 minutes...


Eric(Posted 2006) [#23]
:)