Weird Bug

BlitzMax Forums/BlitzMax Programming/Weird Bug

Czar Flavius(Posted 2011) [#1]
My game is freezing in multiplayer games for some unknown reason. It's very difficult to replicate and can happen at any time. There is no error or message, it just freezes and interestingly freezes on both computers at the same time. This suggests an error in my code, but the bug happens in a really weird place.

I have an option for the game to output logs to a file but the game freezes in the middle of writing a line of this log. But the freeze can also occur with logs disabled.

This is the last two lines of the log.
1185:5927: Updating 3.51 Upholder Cannon 3200,19840 Omega.
1185:5927: Updating 3.52 Upholder Cannon 


Here is some log writing code extracts.

Function multilog(s:String)
	If TSettings.multi And logfile
		If s.Contains("Server") Then Return
		logfile.WriteLine String(game.current_com_turn()) + ":" + String(game.current_work_turn()) + ": " + s + "."
	End If
End Function

multilog "Updating " + unit.debug_info()

Method debug_info:String() Final
	Assert Not _REMOVED
	If TSettings.multi And logfile Then Return _sub_debug_info()
End Method

Method _sub_debug_info:String()
	Return get_id() + " " + get_name() + " " + get_accurate_position().ToString() + " " + get_owner().get_name()
End Method

Method ToString:String()
	Return x + "," + y
End Method


What is very weird is how the file cuts out midline, but it should only get to the writeline once the final string has been fully formed, right??

Last edited 2011


Floyd(Posted 2011) [#2]
I assume that data sent to a file really goes to a buffer in memory. When it builds up to a certain size a block of it is then sent to the actual file. That might explain how it seems to cut off in the middle of a line. There is still some data in the buffer which never gets to the file.

Of course even if this is correct it doesn't help find the real bug.

What is the size of the log file? If it is an exact multiple of 1KB or whatever that would support my "pending data" theory.