Author Topic: The Y targetting bug, possible solution  (Read 8457 times)

0 Members and 1 Guest are viewing this topic.

Offline Shade

  • 211
Re: The Y targetting bug, possible solution
Wow. If that really fixed it for good, that almost warrants a version jump on its own... that thing has been a staple of FS2 (though I've never seen it myself) for as long as I've known about the project ;)
Report FS_Open bugs with Mantis  |  Find the latest FS_Open builds Here  |  Interested in FRED? Check out the Wiki's FRED Portal | Diaspora: Website / Forums
"Oooooooooooooooooooooooooooooooooooooooh ****ing great. 2200 references to entry->index and no idea which is the one that ****ed up" - Karajorma
"We are all agreed that your theory is crazy. The question that divides us is whether it is crazy enough to have a chance of being correct." - Niels Bohr
<Cobra|> You play this mission too intelligently.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: The Y targetting bug, possible solution
Has anyone ever gotten this crash using a debug build?

Nope; that was a major complaint when the bug first reared its ugly head:

Now I know what it feels like to be a quantum physicist. :rolleyes:

It seems that the "Y" targeting bug doesn't want to be found out.  I have determined that the crash occurs in hud_reticle_pick_target in hudtarget.cpp, but I can't figure out anything more than that, for the following reasons.
1) The crash doesn't occur using the debug build.
2) Any attempt to trace through hud_reticle_pick_target causes the bug to not occur. :confused:

I just compiled and ran two versions of fs2_open_r... one with no modifications to hudtarget.cpp, and one with just three commands spaced at beginning, middle, and end of the function that printed a number to a file.  The no-mod build crashed, while the trace build worked just fine. :wtf:

Okay.  Following Phreak's suggestion, I systematically rolled back each file committed on 2/16 to pinpoint the error.  The results are disturbing.

The 'Y' targeting bug was introduced in weapons.h, when version 2.6 was updated to version 2.7.

This doesn't make any sense!  Look at the CVS diff between those two versions.  The changes were trivial - one #define and two float declarations.  Why on earth would this introduce a bug?!?  Could the size change of the BWI struct have anything to do with it?

EDIT:  See if this does anything different: http://icculus.org/~taylor/fso/testing/20060614-win32r.rar

I'll try it tonight.  Does this use the original code?

 
Re: The Y targetting bug, possible solution
I think this one did the trick. I selected many debris from asteroid to ship debris and no crash so  :yes: way to go!!

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
This actually should have been figured out earlier, it's almost too easy not to have been.  Lets look at what we know:

1) only happens on Windows.  Both Linux and OS X don't have this problem
2) the code has hardly been touched since the original source release
3) possible cause 1, the timer asm, wasn't the problem
4) possible cause 2, the debris filtering, rewriten yesterday so thay shouldn't be it
5) only happens in release builds
6) doesn't happen in release builds when you are trying to trace it

At this point only one thing should be making your ears perk up... compiler optimizations.  Yep, the only thing different between the build that works and the one that doesn't is the compiler optimizations.  Specifically it's "Global Optimizations" (/Og) in MSVC.  I tested 9 different builds with various optimization settings and having that one option enabled made it crash every single time.  The 20060614 build is the same code as the 13 one but with the optimizations set at "Maximum Speed" instead of "Custom".

So, after we test it against a build without any of the code changes from me, we can know for sure that the one option is the problem.  We can either disable it with a #pragma in hudtarget.cpp (I think that will work anyway) and leave the optimizations as they are, or just use the "Maximum Speed" option for release builds.

Of course the biggest problem for me was just tracking down a Windows box to test with. :)

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: The Y targetting bug, possible solution
Yay! :)

 
Re: The Y targetting bug, possible solution
Taylor, you've done it.  It even passes the FEP:Battlefield test, with the reticle avoiding debris for actual targets.  I knew something funny was going on when the last kara build had the crash, but when I tried to get a spew with a debug build it never happened.  Again, fantastic work.

 

Offline wolf

  • 25
Re: The Y targetting bug, possible solution
At this point only one thing should be making your ears perk up... compiler optimizations.  Yep, the only thing different between the build that works and the one that doesn't is the compiler optimizations.
I would double check if it's really broken optimization and not some bugs in code that are triggred by these optimizations. Simply starting game and exiting results in several conditional jumps/uses of uninitialized values being detected by valgrind.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
I would double check if it's really broken optimization and not some bugs in code that are triggred by these optimizations. Simply starting game and exiting results in several conditional jumps/uses of uninitialized values being detected by valgrind.
I've run it through Valgrind many, many times and it hasn't hit on this code (that I ever remember at least).  You are going to find quite a few Valgrind messages about conditional jumps and uninitialized values, I've already fixed more than half of them, but I don't think I've never had it hit on the targetting code.  This has only ever been an issue for Windows release builds.  I've never been able to recreate this issue with GCC, even with most every optimization enabled and maxed out.  There is nothing all that strange with that code anyway (other than it being outdated and needing to be replaced).  The same basic methods are used in many places in :v:'s original code.

It is going to get double checked though.  I had quite a few code changes there in these test builds which could have attributed to it working.  It won't be considered 100% fixed until it's verified to work in a build without those changes (which, so far, it has).

 

Offline ]C[rusader

  • 24
  • Ouch.
Re: The Y targetting bug, possible solution
Many thanks for resolving this, and a tip of the hat to the persistence required to do so.

Incidentally... the nature of the problem being compiler-related, it reminds me of a young coder in college who couldn't get a homework program to function at all.  The teacher examined the source and found every line commented out; she asked "why on earth did you do that??", to which the young coder replied:

"Well, that's the only way i could get it to compile."
Open foot, insert mouth.

 

Offline Mongoose

  • Rikki-Tikki-Tavi
  • Global Moderator
  • 212
  • This brain for rent.
    • Steam
    • Something
Re: The Y targetting bug, possible solution
I'm a very neophyte coder, so I didn't even know that something like changing an optimization setting could do something like this.  (Come to think of it, I've never even used an optimization setting. :p)  Do you have any specific idea why that setting would have borked this specific targeting function, or is that question just best left unanswered?  Regardless, this is great news; it was only recently that I started encountering this bug (or at least, that I realized that I was encountering this bug), but even in that short time, I learned to be very careful with the Y key.  It'll be great to go back to targeting whatever and wherever I please. :)

 
Re: The Y targetting bug, possible solution
Somehow, while this bug has greatly annoyed me, I can't help at being slightly amused. I with goober, definetly Quantum physics vibe here as you can't find it when you're looking for it.  Can't you track exactly what the global Optimisation option is doing and see which exact optimisation is causing the crash? I'm a code newb so I'm not sure if its even possible.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
Well, there is more to it than just /Og, but it's the easy fix and doesn't hurt much.  If you notice, I said that it works with /O2 ("Maximum Speed"), which the test build was compiled with.  /O2 basically implies /Og, though it doesn't crash.  But we need something to work for 3.6.9 and simply removing /Og fits the bill.  After 3.6.9 is out we can afford to spend the time to figure out in greater detail exactly what series of compiler optimizations is doing this.  Also at issue is that /Og is obsolete, even in MSVC6, and Microsoft recommends not using it.  So though /O2 may do basically the same thing, it may not have the same optimization issue.

This is just the nature of compiler optimizations, though I'm not good enough to go much futher in figuring this out than I already have.  The optimization aggressiveness/bugs can vary from compiler to compiler, even different versions, so it's just something to be aware of.  The Linux version had issues with certain optimization settings in GCC3, but it's largely ok in GCC4, for instance.  So using the same basic settings in VC++ 2005 that you use in VC++ 6 may give slightly different results.  Giving a detailed account of exactly what is going on here is over my head though.

As far as broken code goes, well we know the problem function and at least 4 coders have been through it in great detail over the past 3 years.  Exactly what in there is the issue will take someone smarter (or luckier) than the rest of us to identify.  I even replaced most of the code which we thought was at issue for the first test build, and it still crashed.

 

Offline Polpolion

  • The sizzle, it thinks!
  • 211
Re: The Y targetting bug, possible solution
'Y' targeting? Y-axis or 'target ship in reticle'?

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
'Y' targeting? Y-axis or 'target ship in reticle'?
'Y' as in 'target ship in reticle' (the default key for that action).

 
Re: The Y targetting bug, possible solution
Taylor, could you please check my error reports in the RC2 thread, the issue is still in some .dll file. Earlier builds work fine.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
Taylor, could you please check my error reports in the RC2 thread, the issue is still in some .dll file. Earlier builds work fine.
I think it's something with your OpenAL setup.  Make sure you are using the newest version of OpenAL (http://www.openal.org/downloads.html), and don't have ct_oal.dll or nvopenal.dll in your system32 directory.

 
Re: The Y targetting bug, possible solution
I have nvopenAL, however it being listed as an Nvidia file makes me wary to just delete it.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
I have nvopenAL, however it being listed as an Nvidia file makes me wary to just delete it.
Just move it to a different directory then.  The nvidia drivers are older than the current version required (ie, I don't think it's proper 1.1).  Basically it's falling back on that hardware specfic version and that dll is incompatible.  It can cause the builds and launcher to hang and/or crash.

 

Offline Colonol Dekker

  • HLP is my mistress
  • 213
  • Aken Tigh Dekker- you've probably heard me
    • My old squad sub-domain
Re: The Y targetting bug, possible solution
Hows the Y target bug solution going,? I had my first error after reading this, I cidn't believe it could happen to me until now
Campaigns I've added my distinctiveness to-
- Blue Planet: Battle Captains
-Battle of Neptune
-Between the Ashes 2
-Blue planet: Age of Aquarius
-FOTG?
-Inferno R1
-Ribos: The aftermath / -Retreat from Deneb
-Sol: A History
-TBP EACW teaser
-Earth Brakiri war
-TBP Fortune Hunters (I think?)
-TBP Relic
-Trancsend (Possibly?)
-Uncharted Territory
-Vassagos Dirge
-War Machine
(Others lost to the mists of time and no discernible audit trail)

Your friendly Orestes tactical controller.

Secret bomb God.
That one time I got permabanned and got to read who was being bitxhy about me :p....
GO GO DEKKER RANGERSSSS!!!!!!!!!!!!!!!!!
President of the Scooby Doo Model Appreciation Society
The only good Zod is a dead Zod
NEWGROUNDS COMEDY GOLD, UPDATED DAILY
http://badges.steamprofile.com/profile/default/steam/76561198011784807.png

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: The Y targetting bug, possible solution
Hows the Y target bug solution going,? I had my first error after reading this, I cidn't believe it could happen to me until now
Just test it again in RC3, which is going up in the next few minutes (or however long it takes to finish building/uploading the Windows binaries).