Random Crashing

BlitzMax Forums/BlitzMax Programming/Random Crashing

KrayzBlu(Posted 2006) [#1]
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...


GfK(Posted 2006) [#2]
Crashes how? What error messages are you getting, and where?


KrayzBlu(Posted 2006) [#3]
It just dies during runtime, and I'm not getting any error messages, from BM at least.


skidracer(Posted 2006) [#4]
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?


KrayzBlu(Posted 2006) [#5]
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 :/


KrayzBlu(Posted 2007) [#6]
Just looking at the second section, was there anything changed in the last update with for/eachin that would cause the program to crash?


H&K(Posted 2007) [#7]
Is npclist a list of Type Character?


KrayzBlu(Posted 2007) [#8]
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


Fabian.(Posted 2007) [#9]
If npclist is a TList object this
Print Len(npclist)
shouldn't compile, should it?


KrayzBlu(Posted 2007) [#10]
Huh? That always worked for me! Is Len() not supposed to work on Tlists??


Gabriel(Posted 2007) [#11]
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.


Fabian.(Posted 2007) [#12]
Strict
Framework brl.blitz

Local N
WriteStdout Len N
??? It compiles and prints 1!!!!!
I think it is a bug.


Fabian.(Posted 2007) [#13]
@Gabriel
Yes it also works in superstrict, really wired!


Gabriel(Posted 2007) [#14]
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.


KrayzBlu(Posted 2007) [#15]
whoops? -> Would that be the cause of crashing do you think?


Gabriel(Posted 2007) [#16]
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.


KrayzBlu(Posted 2007) [#17]
"GC setMemBit: membit already set!"

Does this have anything to do with it?


H&K(Posted 2007) [#18]
@KrayzBlu,
You should really be using Strict or superstrict.
(Not that it will help here, but it does produce better code)


KrayzBlu(Posted 2007) [#19]
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?


Leiden(Posted 2007) [#20]
Try using GCSuspend at the very start of your program. Does it want to run now?


KrayzBlu(Posted 2007) [#21]
Yeah, that does it. Is it going to wreak much havok with the memory if I leave it there?