Funny "bugfixes"
Moderator: InsideQC Admins
10 posts
• Page 1 of 1
Funny "bugfixes"
Have you ever had your code behaving badly for seemingly no reason, and then you accidentally "fix" it in a way that makes even less sense?
In Makaqu, I've got this little check to make sure that the particle metadata only gets recreated when actually needed:
However, in the Windows version it wasn't working properly, so every time the FOV was changed the particle metadata would be recreated, causing lots of unnecessary stuttering in the framerate when zooming.
So, I decided to print out the contents of the aspect variables, since they were the most likely to be malfunctioning:
And then, when I typed "developer 1" in the console and zoomed in... nothing was printed. And no stuttering happened. The check was definitely working this time.
So, I removed the Con_DPrintf lines, and... the stuttering came back. I put the lines back in, and the stuttering was gone again. Then, I tried removing only the first Con_DPrintf line, and the stuttering was still gone. And finally, I put the first line back in and removed just the second line, and it was still gone. So, adding a Con_DPrintf line after the check made it so the check, which is run before the Con_DPrintf, don't fail. It makes no bloody sense at all
.
Things like this can be embarrassing, but it was impossible to not laugh.
In Makaqu, I've got this little check to make sure that the particle metadata only gets recreated when actually needed:
- Code: Select all
// doubled the minimum size here to make sure the particle will appear,
// since the width and height calculations reduces its drawing area
max_size = min (vid.width, vid.height) + 2;
// don't recalculate when only zooming in
if (r_particles_init
&& r_particles.h_aspect == h_aspect
&& r_particles.max_size == max_size
)
return;
However, in the Windows version it wasn't working properly, so every time the FOV was changed the particle metadata would be recreated, causing lots of unnecessary stuttering in the framerate when zooming.
So, I decided to print out the contents of the aspect variables, since they were the most likely to be malfunctioning:
- Code: Select all
Con_DPrintf ("r_particles.h_aspect %d\n", r_particles.h_aspect);
Con_DPrintf ("h_aspect %d\n", h_aspect);
And then, when I typed "developer 1" in the console and zoomed in... nothing was printed. And no stuttering happened. The check was definitely working this time.
So, I removed the Con_DPrintf lines, and... the stuttering came back. I put the lines back in, and the stuttering was gone again. Then, I tried removing only the first Con_DPrintf line, and the stuttering was still gone. And finally, I put the first line back in and removed just the second line, and it was still gone. So, adding a Con_DPrintf line after the check made it so the check, which is run before the Con_DPrintf, don't fail. It makes no bloody sense at all
Things like this can be embarrassing, but it was impossible to not laugh.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
Re: Funny "bugfixes"
I had my share of unexplainable things like that to so your not alone 
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Funny "bugfixes"
Did you leave developer 1 set the whole time? (ie, even when the Con_DPrintf statements were gone). If not, it might actually be a bug somewhere else. If so, I'd suspect a compiler bug.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Funny "bugfixes"
Most possibly a sneaky stack corruption bug, although a compiler bug is not impossible either.
- szo
- Posts: 132
- Joined: Mon Dec 06, 2010 4:42 pm
Re: Funny "bugfixes"
id lean on a compiler bug most of the times i had these kinda weird behaviours switching to another compiler made it go away or revealed a mistake on my part.
it seems to be predominant with later versions of msvc (mostly 2008) better in the latest but still there at times with 2010.
Its like the compiler sometimes thinks it should use minimal rebuild even if told not to and then fails to pickup the change you made untill you force it.
it seems to be predominant with later versions of msvc (mostly 2008) better in the latest but still there at times with 2010.
Its like the compiler sometimes thinks it should use minimal rebuild even if told not to and then fails to pickup the change you made untill you force it.
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Funny "bugfixes"
That sounds like a bug in the dependency generator. Can be tricky to get right, sometimes.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Funny "bugfixes"
Sounds likely should update ms about this i think.
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Funny "bugfixes"
If you've got minimal rebuild enabled that might happen; also if optimizing for size. Another possible cause is that the compiler might somehow have thought that the "if" had no effect and decided to optimize it out; adding the Con_DPrintf convinced it otherwise. Try splitting it out to another function with a #pragma optimize ("", off) on it and see if it reproduces.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Re: Funny "bugfixes"
Its like the compiler sometimes thinks it should use minimal rebuild even if told not to
Thats the problem it seems to sometimes force minimal rebuild even if that option was newer used
Disabling optimization on certain code parts might help though
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Funny "bugfixes"
Well, the compiler I use is the free one from Microsoft Visual C++ Toolkit 2003, which if I recall correctly was said to be more complete than the one used in the Express editions. I may try something else later.
Minimal rebuild bugs aren't a problem, as I always clean the whole build when editing header files, or before compiling release candidates.
Disabling optimizations is a good idea, I've forgot to try that.
Minimal rebuild bugs aren't a problem, as I always clean the whole build when editing header files, or before compiling release candidates.
Disabling optimizations is a good idea, I've forgot to try that.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest