Think I found a bug

Monkey Forums/Monkey Programming/Think I found a bug

Jeit(Posted 2012) [#1]
While going through my code replacing magic numbers I think I stumbled across a bug. I have a field in a different class, level, called _blockSize, its value is 22. When I was replacing 22's with _blockSize I discovered that wherever I had a for loop stepping 22, it would glitch out when I put _level._blockSize there, popping up a window that says "Memory Access Violation" . I don't know what it means, just figured out what was causing the error through trial and error.


BlitzProg(Posted 2012) [#2]
Memory access violation errors usually pop when you attempt to access the field of a null object. Your description is way too vague, this is the only thing I can think off... You should put a piece of code to show us what you're doing and we'll tell you what's wrong.

Anyway if _level = null, you're not allowed to access _level._blockSize, since it's non existent. Are you sure _level is properly defined?


andrew_r(Posted 2012) [#3]
Josh - See if you can come up with a small self-contained sample that duplicates the behaviour.

I should point out that this was a compile-time memory exception so it was definitely a bug in Trans. You shouldn't be able to blow up Trans with bad code :) (It happened during the compile stage in the Jungle IDE - so there's a small possibility it could be a Jungle bug, but it looks like Trans is definitely the culprit.

Andrew


Gerry Quinn(Posted 2012) [#4]
You can't actually have a variable step size in Monkey.

Local x:Int = 2
For local i:Int = 0 Until 10 Step x
     Print i
Next


...should give a compile error.

Could it be that it expects blocksize to be a constant because it's in a different file, and this leads to a bug rather than a compile error?


DruggedBunny(Posted 2012) [#5]
Yeah, best if you try to narrow it down and post an example that causes the error.


Jeit(Posted 2012) [#6]
I have received two different errors, one was it saying I couldn't use a field there because it required a constant step size, the other was what I described. I will make a new program to try and isolate it and post it here as soon as I'm done.


Jeit(Posted 2012) [#7]
so far I am failing miserably at replicating this in a snippet, I can come up with the normal error of "Error : MemberVarExpr(VarExpr(Global _helper:Helper),Field Helper._block:Int) cannot be statically evaluated.", however I cannot seem to get this error again

Still working on it, but taking me some time.


Gerry Quinn(Posted 2012) [#8]
"cannot be statically evaluated" is what you should be getting. It's what my snippet above will give.

Pretty sure it's just a bug originating from trans not recognising that it can't use blockSize. I'd report it, fix the code (use some other kind of loop) and move on.