Nailing that allusive BUG :)

Community Forums/Technical Discourse/Nailing that allusive BUG :)

Stevie G(Posted 2017) [#1]
I've just spent last couple of days trying to find an annoying bug. Normally, it's the part of programming which I most enjoy but not so much on this occasion.

The bug reared it's head when I'd set up a irregular scenario so I sort of stumbled across it. This was actually quite fortunate as I wouldn't have known the bug existed otherwise.

I followed the usual process of spending hours adding loads of additional on screen and debuglog information which I thought might be relevant. Spent days wading through code, debug logs, writing screeds in my trusty note pad and today I finally found the b*stard!!!

Anyway, I just don't think non-programmer appreciate the satisfaction I now feel. I wouldn't go as far as to say it's better than having a right good ***k but it comes pretty close :)

As you were.

Stevie


Derron(Posted 2017) [#2]
What about writing tests?

I tend to add more and more tests now to save on "change game code, compile, run, play till it happens". Not possible in every situation, but you often dev a lot faster when having a "test.xyz.bmx" to run.


Imho _real_ troublesome bugs have the magic spell "hidden trap" without a big cooldown. So once you thought you fixed a bug it somewhere else opens a new bug (as the "mistake" was taken as "must be that way" when developing the other part).


bye
Ron


Stevie G(Posted 2017) [#3]
@Derron,

Like you, I write alot of stuff to my own debug log and there are dedictated debug flags and functions which can be set for just about every aspect of every process. It makes tracking down most issues fairly painless but this one was a bit different as it was introduced long before the error occured and it related to functions I hadn't touched in over a year.

Half the battle is recreating the issue regularly. Once I could do that I eventually knew what variable state was causing the errors and I could stop the execution at that point and examine all the relevant values in the log.

It's definately gone ...


MadJack(Posted 2017) [#4]
When a lawyer alludes to his client's poor mother, he is being allusive.

When the mole keeps eluding the traps you've set in the garden, it's being elusive. We also speak of matters that are difficult to understand, identify, or remember as elusive.


RemiD(Posted 2017) [#5]

this one was a bit different as it was introduced long before the error occured and it related to functions I hadn't touched in over a year


This happened to me too. You consider that a procedure/function is correct because it produces corrected results in many cases but not in all cases. And then you end up searching a bug in newly created procedures/functions when there is no problem there.


About debugging, personally, i use several approaches :
->make sure that the spelling of each variable/function (newly written) is correct
->make sure that the scope of each variable is correct (local/global)
->check that the flow is as wanted using debuglog()
->check that the variables are modified correctly using debuglog()
->check that the results of the calculations are correct using debuglog() and an external calculator
->use markers (images or meshes or pixels/texels) to debug visually what is happening
->split the procedure/function in smaller steps to determine which steps are correct and which are problematic


The frustrating thing is when you realize that the bug is not coming from your mistake(s) but from the language/engine... (linepick on a ROAMterrain bug, updateworld wrong normals bug, setbuffer/viewport bug, ...)


Stevie G(Posted 2017) [#6]
Aye, very good Madjack - elusive it is!!


The frustrating thing is when you realize that the bug is not coming from your mistake(s) but from the language/engine... (linepick on a ROAMterrain bug, updateworld wrong normals bug, cameraviewport bug, ...)



The worst one I had with B3d was where the camera rendered nothing after a while of playing my game. There was no error but the camera was being positioned at Nan,Nan,Nan. Had the game running all day for over a week producing logs etc.. and it turned out that the issue was with a global Pivot I was re-using for thousands of calculations each frame, including the camera positioning. Eventually B3d just didn't like it. The resolution was to reset the scale, position and rotatation each frame. A bit of a cludge but worked :)


Matty(Posted 2017) [#7]
In my space game and variants of it I have a non critical bug - it is a visual thing that is impossible for me to track down as being either part of my code or part of the third party code I'm using (that I cannot edit).

It is the visual appearance of a laser. Every so often the laser beam appears at a funny location parallel with where it would be firing but out of position. I notice it but the casual player doesn't even see it. Tracking something like that down has proven impossible for me.


RemiD(Posted 2017) [#8]
@Matty>>if you use a pivot/joint to position/rotate your laser, maybe the pivot/joint has an unwanted position/orientation ?


EdzUp MkII(Posted 2017) [#9]
worst ever bugs are the ones which only ever happen in release mode.


Steve Elliott(Posted 2017) [#10]
Which reminds me, sorry buddy I need to get you some feedback. I have some notes, then Christmas happened.


RemiD(Posted 2017) [#11]
Another example of a stealthy bug, which was not really a bug due to an error in my code or due to Blitz3d (maybe, not sure), but i was using the emulator "Gens" (to analyze the gameplay of a megadrive game) at the same time than Blitz3d, and each time i tried to get a pixel color on an image, the color was wrong, and no idea why. My procedures/functions to get a pixel/texel color always worked well in the past... The cause was apparently that the emulator was doing some hacks in memory and altering the values... Because once closed, and only running Blitz3d, all went well again.


Stevie G(Posted 2017) [#12]
@ Steve, I've been powering on with the coding over the last month so no rush but all feedback so far has been pretty helpful.


Steve Elliott(Posted 2017) [#13]
@Stevie glad to hear mate. I have a few pages of feedback, but not sure if I should email across - or wait until I have properly evaluated the game - I thought the later.

Either way the feedback is largely positive. The game rocks!


Stevie G(Posted 2017) [#14]
@Steve, the more detail the better. Happy to wait but will chin you in a week or so :)


Steve Elliott(Posted 2017) [#15]
haha a week sounds good, I'll have completed by then :)