Random Crashing
BlitzMax Forums/BlitzMax Programming/Random Crashing
| ||
Hi, I've been having trouble with my porgram crashing at somewhat random places in my code, I and can't think of why it would be crashing. I've just made sure I've got .24 and Sync'd my mods, so there's nothing wrong there... I've isolated the problem to two different lines, the first is a string method. If (kname.contains(","))- Crashes kname is of course a string. But if I put a print call before that line, my program doesn't crash there. Print kname If (kname.contains(","))- Doesn't Crash The second is a Tlist with 1 element. Print "NPCs" Print Len(npclist) For n:Character = EachIn npclist Print "NPC 1" - Prints out "NPCs 1", and doesn't print "NPC 1". And yes, the list contains "character" objects. Does anyone know what I am doing wrong here? This is driving me crazy... |
| ||
Crashes how? What error messages are you getting, and where? |
| ||
It just dies during runtime, and I'm not getting any error messages, from BM at least. |
| ||
Are you using Strict? Without Strict the slightest spelling mistake can cause strings to be uninitialized objects that will crash if invoked like your first example. You are in Debug mode? BTW a crash on Apple I usually regard as an event that will cause the OS to dump a large log into the output window. If you are in debug mode, the debug tree on the right should allow you to analyze the state of your code for a standard BlitzMax runtime error. If the program just silently exits completely (stop button disabled) does it say anything in the output window? |
| ||
Its wierd that when it crashes, no error log comes up, the output window says that the program is completed (which it isn't becuase I'm using the data printouts) and the debug tree on the right is empty even though I am in debug mode. I'm not using strict, but I've gone over all of the relevant data, and there's no spelling errors :/ |
| ||
Just looking at the second section, was there anything changed in the last update with for/eachin that would cause the program to crash? |
| ||
Is npclist a list of Type Character? |
| ||
Its a TList Object. And yes, it only contains Character objects. Do I have to assign the list a certain object type?? So I went ahead and turne on Strict, now my program crashes at the end of a for loop, but this time it spits out "GC setMemBit: membit already set!" I have no idea why its doing this, but has anyone seen this beore? ~Thanks |
| ||
If npclist is a TList object thisPrint Len(npclist)shouldn't compile, should it? |
| ||
Huh? That always worked for me! Is Len() not supposed to work on Tlists?? |
| ||
Fabian: You would think it shouldn't, but it does, even in SuperStrict. ( Bug? ) It doesn't return a useful result, of course, because it's for strings and arrays. It seems to return one on TLists, regardless of the number of elements in them. |
| ||
Strict Framework brl.blitz Local N WriteStdout Len N??? It compiles and prints 1!!!!! I think it is a bug. |
| ||
@Gabriel Yes it also works in superstrict, really wired! |
| ||
I suppose the logic is that it could be used on an array of TLists and if you don't have an array, it's pretty much the same as an array of size one. Perhaps that's how it works internally, anyway. Perhaps no one imagined anyone would use it get the length of a list. I know I didn't. |
| ||
whoops? -> Would that be the cause of crashing do you think? |
| ||
Since you're only printing the output, and it doesn't crash immediately, it's probably unlikely. Only way to be sure is to remove it and see if it helps. |
| ||
"GC setMemBit: membit already set!" Does this have anything to do with it? |
| ||
@KrayzBlu, You should really be using Strict or superstrict. (Not that it will help here, but it does produce better code) |
| ||
Ok, I'm really starting to get mad at strings now. First it was crashing because I used string.tolower(), now its crashing becuase I'm using a slice. Both times it blames GC: GC clrMemBit: membit not set! Has anyone else run inot this at all? |
| ||
Try using GCSuspend at the very start of your program. Does it want to run now? |
| ||
Yeah, that does it. Is it going to wreak much havok with the memory if I leave it there? |