Game Development Community

Torque 3D's Achilles heel

by Konrad Kiss · in Torque 3D Professional · 03/24/2012 (11:49 am) · 184 replies

Recently I spent some time getting myself familiar with static code analysis and the more common (indie-budget freindly) tools associated with the topic. #AltDevBlogADay had several posts about such tools by Bruce Dawson and John Carmack. Definitely worth checking out.

So, it all began with me having a very elusive bug somewhere in code. I hoped that it would be something that a static code analyzer would pick up, so I lined up what I could from trial versions to open source software, and got some amazing results once these went through the Torque 3D 1.2 codebase.

I can't remember if the actual problem was found by these tools (it's been a while ago). What I recall is being taken aback by the results I got. But first a disclaimer...

I've been reviewing engine code changes for the past 4 years. Torque 3D is huge. One of the most surprising thing was the fact, that these code analyzers could - proportionally - find only a few problems. However, the few they did find were hard to see even when I knew the problem.

The kinds of problems I found primarily were:
- Uninitialized member variables used without initialization
- Checking the existence of an object and using the same object outside the check condition
- Passing local pointers that could become invalid
- Using && instead of &, || instead of | operations
- Bad casts for variables while the code assumes another cast (ie. U32 vs S32 - especially when negative values are used for error codes - common in some of the linked libraries)
- Typos, cut & paste programming mistakes that compile (probably the most vicious of all)

I'm only going to list my favorites, hoping that this will be a big enough motivation for everyone to start using some basic form of static code analysis. The complete list would be way too long for me to list here.

gfxD3D9TextureManager: using boolean evaluation against variables that were clearly intended to be bitmasks.
if (retTex->mProfile->isRenderTarget() && mslevel != 0 && (mDeviceCaps.Caps2 && D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES))

guiIconButtonCtrl.cpp: find the highlighted button, I dare you
ColorI fontColor   = mActive ? (highlight ? mProfile->mFontColor : mProfile->mFontColor) : mProfile->mFontColorNA;

processedFFMaterial.cpp: making sure (though what about blendDest?)
result.blendSrc = GFXBlendOne;
      result.blendSrc = GFXBlendOne;

mRectF.cpp: intersectTriangle
if(contains(a) || contains(b) || contains(b))

winDInputDevice.cpp: POV_down, not much of a choice (twice in the same file)
newEvent.objInst = ( objInst == 0 ) ? SI_DPOV : SI_DPOV

rectClipper: clipRect (near eof)
out_rRect.extent.x = bottomR.x - out_rRect.point.x + 1;
   out_rRect.extent.x = bottomR.y - out_rRect.point.y + 1;

win32Window.cpp: equilibrium
newLeft = mClamp(newLeft, 0, newLeft);
      newTop  = mClamp(newLeft, 0, newTop);


Finally - I need to clarify - by all means, no disrespect was intended towards Torque 3D developers. I would have done far worse most likely. I can't count the many new things in the source that made me go "Wow" and "Yey" - it is clearly visible that the team is bigger and better at what they do. Torque 1.2 is the best Torque yet - and I mean it by comparing the overall usability, the number of bugs, etc..

With this post I'm only trying to point at a solution that can save everyone from such blatant bugs in the future, while - perhaps - also nudging GG a little to take a step in the right direction. ;)

Cheers
--Konrad
#101
05/14/2012 (4:59 pm)
Quote:I'd like to say I also fired up an AWS instance, but no.. I had some whiskey instead. :)
LOL

Now, I am going to borrow that line for whatever thing I did in my mind, but did not do in real life:
I'd like to say I also <insert something of significance>, but no.. I had some whiskey instead. :S

I did vary the smiley on the end to account for the consumption of the whiskey.
#102
05/15/2012 (1:41 am)
@John

Basically I read that TFS have issues with offline and online, and the problems that arise when it doesn't discover changes because of it. That to me is enough to stay away from it. It is one thing to deal with conflicts, another to deal with code being missed entirely.

I don't remember the exact search on Google I did yesterday, but it was something along the lines of 'team foundation server issues 2012'. I usually check before commenting on things. And that search made me lift my left eyebrow :)

But as I said, I could be wrong of course. I haven't used it for many many years, and even then not very seriously as we used CVS then.

So don't take my comment too seriously.

#103
05/15/2012 (7:00 am)
@Michael, I've not encountered the online/offline issues since TFS 2008 (and because I travel a lot, I am frequently going on and off line).
#104
05/15/2012 (11:43 am)
I would strongly recommend having individual account authentication for reporting purposes. It keeps lawyers happy, especially where this is not for a specific company or project, but a community organized repo of general purpose additions.

I've done a lot of work and research for CSA's as well, which would help provide a clear means of rolling any changes in the repo back into the core trunk in the future if that is intended down the road.
#105
05/15/2012 (2:41 pm)
My current test platform on the vps:

Trac Service: https://lab.collateral-studios.eu/trac/
SVN Service: https://lab.collateral-studios.eu/svn/

demo user: testuser
demo password: tespassword

Note: Only ssl connections are allowed
#106
05/15/2012 (3:11 pm)
Looks like it's working for me Alfio.
#107
05/15/2012 (3:32 pm)
@Alfio nice, working for me

I'd also be interesting in supporting this with a monthly sum if it meant a monthly patch/diff...this would allow those with lesser coding skills like myself to be able to benefit from the Community Edition as well...I also see it as quite a good learning opportunity - reviewing what changes/fixes are happening...
#108
05/15/2012 (3:46 pm)
@Alfio

Works great Alfio. Great work :)
#109
05/15/2012 (9:59 pm)
@Alfio

Works for me.

Best regards
Kaj

EDIT. The demo password is "misspelled", needs a 't' inbetween, then it worked :-)
#110
05/18/2012 (11:39 am)
Works, I get a certificate validation error for the ssl connection but I can connect to it.

Any word on when we could get an official seal of approval from GG?
#111
05/18/2012 (11:42 am)
(double post argh)
#112
05/18/2012 (11:48 am)
@TheMartian - My original statement stands:

Quote:As far as I know, there is nothing in the EULA that prevents action. There are only two rules. The first is that the repository remain private, obviously. The second is that no one can sell the contents of this repository. That would essentially be re-licensing of the engine.

If we find either of these rules to be violated, then it would need to be shut down. I don't foresee that happening with the people involved, though.
#113
05/18/2012 (11:57 am)
It is normal that there is a certificate problem. In practice, the certificates are valid and working, but not being released from an appropriate authority, and the browser will warn the user. A certificate released by an authorized authority, costs more than $200 for year.

We have the approval of the GG. But must deciding which platform to use, if mine or those that other users have made available.
#114
05/18/2012 (4:12 pm)
@Alfio. Of course some consensus would be needed but since you have already set things up, I think I would be more than happy to jump on your train :)

A self signed certificate is not really an issue, I think we all know who Alfio is right? :)

#115
05/19/2012 (9:18 am)
How stable is the build?
#116
05/19/2012 (10:28 am)
Is a vps with openvz on a *nix machine, and a guaranteed uptime of 99.99%.
I installed debian 6, the most stable *nix like os. All software included in debian is not very new, but in compensation is always stable. I prefer a stable os rather than as a new ubuntu or otherwise.

I'm starting now to put on the svn the T3D 1.2 (vanilla).
#117
05/19/2012 (5:57 pm)
The first commit are completed. Now i can add the users and start to open the tickets on the project manager.

It may be possible to give the opportunity for developers of plugins (like afx or Sahara), to commit their files and provide access to such files only to licensed users, thanks to a system of group management.

MIKE, the XXX plugin developer, will be part of the same group of the user JOE which has licensed the plugin. So only this two user will have access to specific XXX plugin files.
#118
05/19/2012 (7:03 pm)
I meant the torque build :)
#119
05/20/2012 (7:40 am)
Hi,

Great to see that moving on!

I would suggest that we all follow a way of commenting code changes and set the svn commit comment as mendatory with also a rule to write it.

If you are interested, i have a vs macro that will do the trick.
You select the code region, hit your shorcut for the macro. It will ask for the defect number. Them it will set comment before and after the code region.
Example:
//Code changes for defect 1234
... Code...
//End of code changes for defect 1234

We can also add who Did the change.

Is it something you feel useful?
#120
05/20/2012 (8:57 am)
Edit double post