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.
guiIconButtonCtrl.cpp: find the highlighted button, I dare you
processedFFMaterial.cpp: making sure (though what about blendDest?)
mRectF.cpp: intersectTriangle
winDInputDevice.cpp: POV_down, not much of a choice (twice in the same file)
rectClipper: clipRect (near eof)
win32Window.cpp: equilibrium
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
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
About the author
http://about.me/konrad.kiss
#42
05/13/2012 (2:08 am)
I agree, and I also agree it could work. But I think the lawyers would have a thing or two to say about it :) I also have no idea how well protected github projects (private) are.
#43
I'd be happy to support this project however I can :)
05/13/2012 (2:29 am)
Why then stall this really good project; David already gave the official GG greelight as I see it. No need to further talk about if daylight is disguised nigthtime ;)I'd be happy to support this project however I can :)
#44
05/13/2012 (2:42 am)
Konrad is correct in that GitHub is for both public and private hosting. It is free for open source projects with public access. For the purpose needed here there would be a monthly fee necessary ($25/month for the Bronze Business Plan) for private hosting. So long as access was only given to licensees there would be no legal worries. The community involved in it could be considered as one large collaborative effort or team. I'm also fairly sure that due diligence has been done on GitHub's end to ensure security -- probably more so than a home-brew private svn server. There are other alternatives (Xp-Dev comes to mind) as well.
#45
Perhaps we should create a PayPal account for this and have everyone pay a monthly $5 for access. Using these funds we could host the repository over at GitHub but we could also use the remaining sum to hire programmers to add new features or fix important bugs for everyone who has access at any time.
We would risk the project if we had a single person pay for it - think of when that person would lose interest, go bankrupt, etc.
If we do paid for it, and allowed access to any source licensee for $5 we could actually do much more than share a few fixes.
Eventually in a few months we could afford to hire programmers to add stuff we would have a vote on. Resource streaming, fbx import, middleware connectors, etc...
I think it would be a great idea.
05/13/2012 (2:59 am)
Don't panic, but I had an idea:Perhaps we should create a PayPal account for this and have everyone pay a monthly $5 for access. Using these funds we could host the repository over at GitHub but we could also use the remaining sum to hire programmers to add new features or fix important bugs for everyone who has access at any time.
We would risk the project if we had a single person pay for it - think of when that person would lose interest, go bankrupt, etc.
If we do paid for it, and allowed access to any source licensee for $5 we could actually do much more than share a few fixes.
Eventually in a few months we could afford to hire programmers to add stuff we would have a vote on. Resource streaming, fbx import, middleware connectors, etc...
I think it would be a great idea.
#46
With issue tracking and other project management tools we could see a community enhanced version of Torque 3D come about very transparently to all who participate.
It would even be a step beyond what was accomplished with the the TorqueX CEV which was funded by a single person and is surprisingly still open -- maybe Pino could give us some pointers on how to organize and get things going.
05/13/2012 (4:12 am)
I like that idea! With issue tracking and other project management tools we could see a community enhanced version of Torque 3D come about very transparently to all who participate.
It would even be a step beyond what was accomplished with the the TorqueX CEV which was funded by a single person and is surprisingly still open -- maybe Pino could give us some pointers on how to organize and get things going.
#47
If we all agreed on how to solve payments and who should be the ones who took lead then we could be up and running in just a few hours. I volunteer to be one of them but I wouldn't like to be alone with this, because I can't always guarantee availability in the coming weeks and all through the summer.
05/13/2012 (4:54 am)
One problem is though that the PayPal should be under one person's name. If we made an account it would either be only one person accessing it (which is what I wanted to avoid) or multiple people had access but only one would be responsible obviously, which stinks. Unless we created a company for this which is unrealistic. :) Another thing to consider is that a fresh PayPal account would require validation when the account has seen a certain sum moving.If we all agreed on how to solve payments and who should be the ones who took lead then we could be up and running in just a few hours. I volunteer to be one of them but I wouldn't like to be alone with this, because I can't always guarantee availability in the coming weeks and all through the summer.
#48
05/13/2012 (5:20 am)
It's an interesting idea. But I am going to be the worried guy again :) If things are getting enhanced (which I would really love) there is the issue about T3D being split. I would like for enhancements to either be added as plug-ins or if they are given the 'OK' by GG to be implemented in T3D. Because if the sources become too different, it can be quite messy after a while.
#49
05/13/2012 (5:28 am)
@Michael Tornberg: This is not about adding gameplay features, more like fixing existing bugs (whatever our static code analyzers find) and - if the system works - evolving existing engine systems later on. If we do this right, I believe there's a good chance of these changes making it into the official release. Btw, version control is a pretty useful antidote for the ailment you describe. GIT especially so.
#50
05/13/2012 (5:44 am)
I get the bugfixing and I am totally on with that. It's the 'a community enhanced version of Torque 3D' I am having thoughts about (as mentioned by Michael Hall) although I would like to see that happening.
#51
05/13/2012 (5:45 am)
It's the same thing.
#52
Edit: Anyway, let's leave this.. because I feel we are mostly on the same track anyway :)
05/13/2012 (5:58 am)
Uh.., not to be picky but 'bugfixing' and 'community enhanced' is most definitely not the same thing.Edit: Anyway, let's leave this.. because I feel we are mostly on the same track anyway :)
#53
I assume from the sheer amount of helpful comments from you that you are interested in taking an active part in this. Good. We need all the help to get this off the ground. Anyone with a natural gene for constructive criticism is definitely a welcome addition to such an endeavor. Without people like you it's doomed to fail.
I also get the impression that you have some serious background with github since you seemed to be discontent with their security measures. If you had the time to share stories, I'd be interested in hearing more about the flaws of their data protection system in place. I myself have been hosting projects both public and private there for a while now, but I'm always keeping an eye open for good information, if you know what I mean.
Alas, license requirements must be met first. (sadface)
05/13/2012 (6:20 am)
Gah... I'm sure Michael meant the same thing. And even if not, that's what branching is for.I assume from the sheer amount of helpful comments from you that you are interested in taking an active part in this. Good. We need all the help to get this off the ground. Anyone with a natural gene for constructive criticism is definitely a welcome addition to such an endeavor. Without people like you it's doomed to fail.
I also get the impression that you have some serious background with github since you seemed to be discontent with their security measures. If you had the time to share stories, I'd be interested in hearing more about the flaws of their data protection system in place. I myself have been hosting projects both public and private there for a while now, but I'm always keeping an eye open for good information, if you know what I mean.
Alas, license requirements must be met first. (sadface)
#54
Whereas I m very Happy to see so much involvment to get fixes and I Will be Happy to share the one I found, I m just suprised to not see GG more involved in this topics.
I can see old community members and associates looking forward on this idea but no real action from GG.
If the community is able to find 60 bugs, GG should be able to dedicate 1 dev to validate and integrate them in the next release or as an intermediate patch before the next big version.
From what I read there, the community is ready to pay someone to fix bugs, isn t it the rôle of GG? In that case, we should look at setting à support fees that Will allow the members to contribute to fix & engrangement with someone on GG that will validate the changes.
The members that will not pay will have to wait the official release.
What do you think?
In all cases, getting a better product is good for all and I really thanks all of you who are contributing and sharing their work!
05/13/2012 (6:56 am)
Hi,Whereas I m very Happy to see so much involvment to get fixes and I Will be Happy to share the one I found, I m just suprised to not see GG more involved in this topics.
I can see old community members and associates looking forward on this idea but no real action from GG.
If the community is able to find 60 bugs, GG should be able to dedicate 1 dev to validate and integrate them in the next release or as an intermediate patch before the next big version.
From what I read there, the community is ready to pay someone to fix bugs, isn t it the rôle of GG? In that case, we should look at setting à support fees that Will allow the members to contribute to fix & engrangement with someone on GG that will validate the changes.
The members that will not pay will have to wait the official release.
What do you think?
In all cases, getting a better product is good for all and I really thanks all of you who are contributing and sharing their work!
#55
We could be spending the extra subscription money on fixes and then sharing the smaller ones with GG to include in a future version or by sharing them as a patch file each month directly with the community. This would be an ideal way to get the recognition and the subscriber count to keep this going.
We could as well be selling new features back to GG. The ones that cost us money to develop. I can see this being highly beneficial to everyone.
Ideally, GG would be fixing bugs and adding new features. Which they do, but I believe that we can always take matters into our own hands and make things go faster to match our own pace.
I am sure that GG would be interested in this as well. Some of the associates are directly working on code for Torque, so I assume it wouldn't be too hard to push an update through unless GG would be worried about the load this would put on their QA. But who else could do better QA than us, who work with the thing day and night, right?
05/13/2012 (7:11 am)
I'm sure GG will chime in more on Monday. Great ideas btw.We could be spending the extra subscription money on fixes and then sharing the smaller ones with GG to include in a future version or by sharing them as a patch file each month directly with the community. This would be an ideal way to get the recognition and the subscriber count to keep this going.
We could as well be selling new features back to GG. The ones that cost us money to develop. I can see this being highly beneficial to everyone.
Ideally, GG would be fixing bugs and adding new features. Which they do, but I believe that we can always take matters into our own hands and make things go faster to match our own pace.
I am sure that GG would be interested in this as well. Some of the associates are directly working on code for Torque, so I assume it wouldn't be too hard to push an update through unless GG would be worried about the load this would put on their QA. But who else could do better QA than us, who work with the thing day and night, right?
#56
Speaking purely for myself and not for GarageGames, I'm liking this discussion. Here are some points for those of you who have not been around as long. This might just be a review for you long timers:
1. This discussion has happened before. Several times, in fact. I'm referring to community collaboration in a private repository.
2. I have only seen it really go somewhere twice. One was Realm Wars, which is long dead. The other is more recent, which provides some hope. That would be Torque X CEV.
3. 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.
4. I think you would see contribution or help from official GarageGames, but only when all the dominoes are set up. Once it's certain this project will move forward, GG could help tip the first couple.
5. There is much more planning and collaboration with GG if the improvements were to roll back into our official repo. That gets kind of sticky and has to be agreed upfront.
I'm sure there are more talking point, but I just wanted to chime in before the weekend was up. David has his eyes on this post, so maybe we can summarize it for the higher-ups, to see if there is more interest from the shot callers. By all means, keep discussing the details to see if a true plan comes out of this.
05/13/2012 (7:39 am)
@Konrad - Why wait until Monday to hear from someone?Speaking purely for myself and not for GarageGames, I'm liking this discussion. Here are some points for those of you who have not been around as long. This might just be a review for you long timers:
1. This discussion has happened before. Several times, in fact. I'm referring to community collaboration in a private repository.
2. I have only seen it really go somewhere twice. One was Realm Wars, which is long dead. The other is more recent, which provides some hope. That would be Torque X CEV.
3. 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.
4. I think you would see contribution or help from official GarageGames, but only when all the dominoes are set up. Once it's certain this project will move forward, GG could help tip the first couple.
5. There is much more planning and collaboration with GG if the improvements were to roll back into our official repo. That gets kind of sticky and has to be agreed upfront.
I'm sure there are more talking point, but I just wanted to chime in before the weekend was up. David has his eyes on this post, so maybe we can summarize it for the higher-ups, to see if there is more interest from the shot callers. By all means, keep discussing the details to see if a true plan comes out of this.
#57
Ok, so it sounds like getting code back into the official repo is not worth considering at this moment. I'd say it's not such a big deal, because the more subscribers we get the faster we can evolve the code in the repo. And if we directly share results with Torque developers, they will be more likely to jump on board.
Since we don't plan to be working on a community game or features for a specific genre, I have high hopes for this kind of collaboration. I also believe that we move faster if we don't consider GG's help for now - solely because we don't have to wait for outside action then. No disrespect, but response can be understandably slow when the office is busy.
It would be cool to be able to set up a channel through which this work is preserved in the official repository, that would be a noble goal, but from what Mitch says I don't think it's feasible at this time.
If everyone agrees, I am ready to take lead on this and set up the repo. Michael (Hall), would you be willing to manage the repo with me to give out read and read/write access and to verify licensees?
As for PayPal.. if everyone is fine with it, I could temporarily handle payments until a better solution is available so that we get started faster. I can do this through Bitgap's payment system and also prepare a page using the PayPal API for repo moderators and Bitgap registered users to see who has paid what amount and when. Unless there's a better idea of course, or someone has trust issues against me collecting subscription payments through the Bitgap system. (no problem, it's better to say it now than not get enough subscribers and let the project die)
Ideally the payment would directly be connected to access using Github's API, but that'd require a significant amount of time to research. I'll be happy to work on automating the entire system if people are interested at all.
How many of us would be interested? Please drop a line if you would subscribe for $5 a month to continuous bug fixes that the community makes, so we all can get an idea whether it's at all worth the effort we're about to put into this or not.
05/13/2012 (8:24 am)
@Mich: Thanks. I was implying it was a weekend and nobody would be reading this. Proven me wrong. :)Ok, so it sounds like getting code back into the official repo is not worth considering at this moment. I'd say it's not such a big deal, because the more subscribers we get the faster we can evolve the code in the repo. And if we directly share results with Torque developers, they will be more likely to jump on board.
Since we don't plan to be working on a community game or features for a specific genre, I have high hopes for this kind of collaboration. I also believe that we move faster if we don't consider GG's help for now - solely because we don't have to wait for outside action then. No disrespect, but response can be understandably slow when the office is busy.
It would be cool to be able to set up a channel through which this work is preserved in the official repository, that would be a noble goal, but from what Mitch says I don't think it's feasible at this time.
If everyone agrees, I am ready to take lead on this and set up the repo. Michael (Hall), would you be willing to manage the repo with me to give out read and read/write access and to verify licensees?
As for PayPal.. if everyone is fine with it, I could temporarily handle payments until a better solution is available so that we get started faster. I can do this through Bitgap's payment system and also prepare a page using the PayPal API for repo moderators and Bitgap registered users to see who has paid what amount and when. Unless there's a better idea of course, or someone has trust issues against me collecting subscription payments through the Bitgap system. (no problem, it's better to say it now than not get enough subscribers and let the project die)
Ideally the payment would directly be connected to access using Github's API, but that'd require a significant amount of time to research. I'll be happy to work on automating the entire system if people are interested at all.
How many of us would be interested? Please drop a line if you would subscribe for $5 a month to continuous bug fixes that the community makes, so we all can get an idea whether it's at all worth the effort we're about to put into this or not.
#58
05/13/2012 (8:25 am)
I am in the engine regularly and i would be moee than happy to donate my time in administration and programming currently the two cahnges i made lets a dedicated server run 150ai without pegging the server or crashing btw thats the stock aiplayer class not a scaled down ai class ive found little tjings that make big differences and would love to see them in the head if they pass qa and testing
#59
If the code the community write ends up on the official repository of the GG, i do not think there is a problem. At the end the main purpose is precisely to help the development of the engine.
05/13/2012 (8:53 am)
Only a versioning control service (svn, git, or ther), is not enough. The commit should be allowed at all, and then you could create a conflict of management if multiple users work on the same piece code. So i would say that is required also a project manager or something like that. Just not going to change the same code in two users (in my office i use Trac and Collab on a private debian server).If the code the community write ends up on the official repository of the GG, i do not think there is a problem. At the end the main purpose is precisely to help the development of the engine.
#60
Of course, the best would be if the code ended up in the official repository, but Mich says it could take some time.
05/13/2012 (9:09 am)
That's a good point. Still, a project manager would increase the dependency of the project itself. Would it make sense to let those developers who have write access discuss and make a decision for each merge conflict? As for issue tracking, GitHub has that integrated along with forms of communication for the team. Here is some info on what's included.Of course, the best would be if the code ended up in the official repository, but Mich says it could take some time.
Associate Konrad Kiss
Bitgap Games