Error Message "Unhandled Exception: Assert failed"
BlitzMax Forums/BlitzMax Programming/Error Message "Unhandled Exception: Assert failed"
| ||
Could anyone tell me what causes this? |
| ||
Argh, I just had that happen a few weeks ago, and it turned out to be an insanely frustrating stupid little thing. I'm wracking my brains, but I can't remember offhand what it was...part of me wants to say it was forgetting to put a $ at the end of a string variable, but I'm not certain. In the meantime, I'd recommend doing what I did: comment out huge swaths of code at a time until you can narrow down exactly where it is. Good luck! |
| ||
http://www.blitzbasic.com/Community/posts.php?topic=48544 Cyanide apparently encountered this and fixed it, you could try mailing him (or hope he notices this thread). *EDIT* If you do find the solution, it would be good if you could post it here: http://www.blitzwiki.org/index.php/BlitzMax_Errors |
| ||
If you don't tell us which asserttion axactly fails, we'll have a hard time helping you. An assert is a simple statement that checks if an expression is true, and throws an exception otherwise. It helps finding bugs, when you have a condition that *MUST* and is supposed to be true. Here's an example: Framework brl.basic Import brl.standardio Function PrintSqr(a) Assert (a > 0) Else "Can't compute square root of negative integer" Print Sqr(a) End Function PrintSqr(-10)Because PrintSqr is called with a < 0, an exception is raised, and here the program stops. There could be no error message with the assert (just "Assert (a >= 0)"), but even then it's not that hard figuring what's wrong: the offending line should be highlighted in the editor. A last note: such checks are used for debugging purpose, and thus are done only in a debug build. |
| ||
ok heres the code.....i dont have any asserts in it though [edit] i only get this error in debug build [/edit] For Local obj:TGNetObject=EachIn GNetObjects(host) If GetGNetString(obj,SLOT_TYPE)="bullet" And GNetObjectLocal(obj)=True ' this is the line the error occurs at x=GetGNetInt(obj,SLOT_X) y=GetGNetInt(obj,SLOT_Y) f=GetGNetInt(obj,SLOT_F) lastup=GetGNetInt(obj,SLOT_LASTUPDATE) If f=0 And MilliSecs()=>lastup+100 x:+1 lastup=MilliSecs() ElseIf f=1 And MilliSecs()=>lastup+100 y:-1 lastup=MilliSecs() ElseIf f=2 And MilliSecs()=>lastup+100 x:-1 lastup=MilliSecs() ElseIf f=3 And MilliSecs()=>lastup+100 y:+1 lastup=MilliSecs() EndIf If mapsolid[x,y]=SOLID CloseGNetObject(obj) Continue EndIf For pobj:TGNetObject=EachIn GNetObjects(host) If GetGNetString(pobj,SLOT_TYPE)="player" If x=GetGNetInt(pobj,SLOT_X) And y=GetGNetInt(pobj,SLOT_Y) And GNetObjectLocal(pobj)=False CloseGNetObject(obj) EndIf EndIf Next SetGNetInt obj,SLOT_X,x SetGNetInt obj,SLOT_Y,y SetGNetInt obj,SLOT_LASTUPDATE,lastup EndIf Next |
| ||
i only get this error in debug build Assert is a debugging tool - the compiler ignores it when building in release mode. |
| ||
i know that but i would like to be able to use debug mode....there is no Assert in my code |
| ||
Is it possible this is an 'Assert' within core BlitzMax that's failing? If you run the Framework Assistant and then search the directories with those modules you might be able to narrow it down. |
| ||
thats possible......if its failing anywhere i think it would be the GNet module because thts were i get the error. |
| ||
...which has LOTs of assert statements. Could you add debug statements to the Gnet module? |
| ||
Hi, GetGNetString(obj,SLOT_TYPE)="bullet" Are you sure this slot contains a string? GNet will throw an assert of you read a string from an int slot etc. |
| ||
thats the problem! I didnt assign the player's object the type "player" at the beginning, but instead had function which sync. some varibles along with the SLOT_TYPE later in the code. |