Slashdot Mirror


Unreal Engine Code Issues Fixed By Third-party Company

An anonymous reader writes: Unreal Engine is the famous game engine that was used to implement such games as Unreal Tournament, BioShock Infinite, Mass Effect and many more. On March 19, 2014 Unreal Engine 4 was made publicly available from a GitHub repository. It was a big event for the game development industry. One of the companies that took an interest in this was PVS-Studio, who created a static C/C++ code analyzer. They analyzed the Unreal Engine source code and reported to Epic Games's development team about the problems they found. Epic suggested a partnership with PVS-Studio to fix those bugs, and their challenge was accepted. Now, PVS-Studio shares their experience in fixing code issues and merging corrected code with new updates in a major project that shares its source code.

72 comments

  1. New article for a pull request? by Anonymous Coward · · Score: 0

    New article for a pull request?

  2. Problems causing Video effects? by Whiteox · · Score: 1

    The big question for me is do coding errors affect video rendering issues?
    We tend to blame drivers for this, but recently there are opinions out there that suggest that the game code itself is responsible (as well).

    --
    Don't be apathetic. Procrastinate!
    1. Re:Problems causing Video effects? by Anonymous Coward · · Score: 3, Insightful

      Of course they can. If you calculate stupid stuff, the result will be stupid stuff.

    2. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      "When trying to use a pointer to address a destroyed object, undefined behavior occurs. What form it will take is unknown. The program may work well for years if you are lucky enough that the data of the dead object (stored on the stack) is not overwritten by something else."

      RTFA

    3. Re:Problems causing Video effects? by sexconker · · Score: 2

      Only idiots "tend to blame drivers" for that shit.
      The vast majority of changes in driver updates for AMD and nVidia are hacks for specific games to fix their broken shit and get them to not run like ass.

    4. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      That's a huge mess of problems, that I can try to untangle for you.

      Right now, on whatever personal computer you're using regardless of OS, programming for the GPU goes through a third party API. Either Direct X or OpenGL, depending. Regardless of which, the API does a lot of interpretation for programmer, often doing things that might not even be wanted. That's one layer of abstraction from code to execution. The second is that each IHV has different implementations of how this API is actually handled in the GPU itself, meaning different code will end up being executed differently on each GPU depending on manufacturer, and even differently on different generations of GPUs from the same manufacturer.

      Today "Triple A" games have fantastically large codebases as it is. Just getting the thing to work, and quickly, is usually seen as an accomplishment. To then have to go through the abstracted API you're forced to run on for the PC, and then to through and see how the API is handled by each IHV for anything more than making sure "it actually runs kind of ok" is usually too much even for the largest budgeted games. Fortunately for the industry there's three new APIs, Vulkan, Metal, and Direct X12, that are much less abstracted and more "the program does what we say it does precious". So hopefully this will be much less of an issue going forward.

      Of course there are 3 APIs instead of just one, the open development one that can run on anything aka Vulkan, because Apple and Microsoft just HAVE to have their own API instead of using the unclean open development/source one.

    5. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      Garbage In, Garbage Out

    6. Re:Problems causing Video effects? by TFlan91 · · Score: 1

      But guyzz, you forgots about WebGL and JavaScript! Obviously, they all that matter.

    7. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      No matter what the game, no matter what the issue, you will always be told to update your video drivers. Apparently, 99% of the PC gaming community believe that video drivers go stale.

    8. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      This is incorrect. A lot of us used to follow game developer .plans religiously, and we grew accustomed to reading detailed accounts of exchanges between engine coders and nvidia/ATI/matrox. If you pay close attention, you can still find developer commentary about the waiting game for a new driver update that fixes this problem or that problem.

      What you meant to say is that "only idiots *tend* to do things without a reasoned and thoughtful basis for doing so." Back in the day, there was a well reasoned and thoughtful basis for resorting to a default position that shitty ATI drivers were causing all kinds of problems with a lot of different games. That may not be true any longer, but you'd be remiss to say the "vast majority of changes" are hacks to get around shitty game code. This simply isn't true.

    9. Re:Problems causing Video effects? by Anonymous Coward · · Score: 1

      Only idiots "tend to blame drivers" for that shit.
      The vast majority of changes in driver updates for AMD and nVidia are hacks for specific games to fix their broken shit and get them to not run like ass.

      Yeah, "idiots" like Rich Geldreich, an OpenGL expert that worked at Valve for many years. His scathing assessment on the quality of drivers resulted in widespread news coverage, including a /. article. For those of you interested in reading the original post, it's at http://richg42.blogspot.com/2014/05/the-truth-on-opengl-driver-quality.html. Note that most of the other game developers posting in the comments agree with him.

      So, which company are you shilling for, sexconker, vendor N or vendor A? Inquiring minds want to know.

    10. Re:Problems causing Video effects? by Whiteox · · Score: 1

      Holy handgrenades!
      I have built high end gaming systems that replaced older high end gaming systems ad infinitum. Always the problems of the older systems had to do with speed (texture loading for instance) and rendering high framerates at comparatively low resolutions - just for the sake of hurdling over various 'issues'.
      When you realise that there are no bottlenecks in the system but these issues are still present, then you look elsewhere and that elsewhere is coding.
      Those AAA games you speak of are the culprits, forced to publish before they are optimised and depend on updates that may break other things.
      I read different opinions by those who (should) know about driver issues, the last being that both nVidia and AMD have 2 standards, optimised for GPU processing (labs) and another for rendering (games). Others claim that the game code itself (NOT the engine driving it) is complicit with these faults.
      I will assume that coding errors in the game engine will affect the game code, no matter how well it is written.
      In the end and at this time, the purest graphic setup must be a single GPU to avoid hardware jitter and the fastest ram based drive.
      Something must be done with the developer paradigm or it becomes a pretty pointless investment for high end systems, 4K monitors and the like.

      --
      Don't be apathetic. Procrastinate!
    11. Re: Problems causing Video effects? by donscarletti · · Score: 3, Interesting

      You don't know what you are talking about. Drivers never quite follow the DirectX, OpenGL spec and always have some idiosyncrasies on this card or that to make them generate correct-ish results faster by cutting corners. I find my card getting completely different results to the reference implementation on a monthly basis (sometimes even missing draw calls completely or rendering with the wrong state). I found this particularly true when using DX9 style render states on DX11 class hardware. Neither AMD nor Nvidia will change a driver for you unless you can prove to them that the application is using the spec correctly and the observed results are demonstrably wrong. If you are an independent developer it's even worse since they don't make it easy to contact them.

      --
      When Argumentum ad Hominem falls short, try Argumentum ad Matrem
    12. Re:Problems causing Video effects? by Anonymous Coward · · Score: 2, Informative

      Should have used OpenBSD. Freeing a object gets that memory address nuked immediately. Great dev platform for finding bugs because they do everything they can to make undefined behavior break instead of work most of the time.

    13. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      Only idiots call people idiots or refer to idiots. Idiot! And shit!

    14. Re:Problems causing Video effects? by Anomalyst · · Score: 1

      Their lead singer is kinda hot.

      --
      There is no right to feel safe thru security vaudeville at the expense of everyone's freedom, privacy and tax money.
    15. Re:Problems causing Video effects? by drinkypoo · · Score: 4, Informative

      The big question for me is do coding errors affect video rendering issues?

      Sure. Just remember that the video driver is a whole bunch of code. It's code all the way down.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    16. Re: Problems causing Video effects? by Anonymous Coward · · Score: 0

      Shhhh, I explained all this in detailed form but got downvoted to nothingness, because /. is a place for angry yelling rather than any understanding of actual coding,

    17. Re:Problems causing Video effects? by Whiteox · · Score: 1

      Not for me porky. I build them for clients. I wouldn't blow $4~6k on a gaming machine.

      --
      Don't be apathetic. Procrastinate!
    18. Re:Problems causing Video effects? by Zardus · · Score: 4, Interesting

      A long time ago, I set up Siege of Avalon (at that point, already a 5 year-old game) and, upon getting to some specific level, found that performance had gone down the toilet. I fiddled around for a while, then (for some reason) called the support number. They told me to update my video card drivers. I told them that the video card drivers were already about 4.5 years newer than the game itself, and so their suggestion made no sense. We debated for a while, but they stuck to their guns. I hung up, frustrated.

      Updating my video card drivers fixed the issue.

      --
      You can mod your friends, you can mod your nose, but you can't mod your friend's nose.
    19. Re:Problems causing Video effects? by Ihlosi · · Score: 1
      It's code all the way down.

      If you haven't encountered hand-soldered transistors, you haven't gone "down" far enough.

    20. Re:Problems causing Video effects? by allcoolnameswheretak · · Score: 2

      At least the part about:

      The vast majority of changes in driver updates for AMD and nVidia are hacks for specific games to fix their broken shit and get them to not run like ass.

      Is quite true I'm afraid. NVidia frequently releases "Game Ready" drivers tuned for a specific game. Usually for high-profile new game releases, such as the Witcher 3 most recently.

      This most recent batch of new "Game Ready" drivers fucked up my and other users systems by frequently crashing, causing the driver and the display to reset, sometimes even on the desktop while browsing. Sometimes this happens multiple times within a minute, rendering some games unplayable. This is one of the threads on the latest clusterfuck on this issue: NVidia display driver stops responding.

      Still no fix from NVidia.

    21. Re:Problems causing Video effects? by Anonymous Coward · · Score: 0

      But that is (at least partly, maybe majorly) because the game's broken code will be fixed by doing what the game wants to be done, not what the spec says should be done.

      This is entirely the same as games being broken on a new Windows OS because they're coded for the bugs in an earlier Windows OS.

    22. Re:Problems causing Video effects? by ArcadeMan · · Score: 1

      I'm guessing the game was coded properly, according to the specifications of the APIs but the older drivers weren't 100% compliant with the specs of those APIs.

    23. Re:Problems causing Video effects? by drinkypoo · · Score: 1

      Only idiots "tend to blame drivers" for that shit.

      I haven't had to go through this in a while, but there was a long time (back in the GEforce single-digit version days) when you would regularly have to reinstall an old driver to play a specific game. It doesn't really matter whether that old driver had a special case that they took out later, or whether they just broke something; either way, driver changes will regularly take out programs. The driver developer can then go blame it on the software developer, but they may well have done it wrong the first time and the bad behavior in the application may have been a workaround for that. Everyone wants to blame everyone else.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    24. Re:Problems causing Video effects? by drinkypoo · · Score: 1

      If you haven't encountered hand-soldered transistors, you haven't gone "down" far enough.

      Back in high school I built a burglar alarm kit, does that count? It was enough to convince me that what I really wanted to do was use microcontrollers, or better. Now that you can just buy I2C modules and plug them together, I feel relatively vindicated. Someone has to design those things, but it doesn't have to be me.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    25. Re:Problems causing Video effects? by Lothsahn · · Score: 1

      My understanding is that graphics APIs don't specify performance for any particular method (every method should just execute "as quickly as possible"). This means that updated drivers may introduce performance regressions in one code path to optimize another path and this is perfectly acceptable according to the API. As long as no testing covers that code path (no recent games, etc), regressions are often introduced in later driver versions for older or less-used code paths. Testing is focused around the current games and releases, because that's what 99% of people use.

      In general, performance regressions and bugs are often introduced in graphics drivers for older games. If you're having performance, glitches, stability, or other problems in an older game, it ALWAYS helps to check to see if a graphics driver update fixes it. If it doesn't, downgrade the driver to an older version--as the older version was much more likely to be tested with your game.

      HTH

      --
      -=Lothsahn=-
    26. Re:Problems causing Video effects? by Eunuchswear · · Score: 1

      Read the message you are replying to:

      The program may work well for years if you are lucky enough that the data of the dead object (stored on the stack) is not overwritten by something else.

      FreeBSD nukes the stack when a stack frame is deallocated? I think not.

      --
      Watch this Heartland Institute video
    27. Re:Problems causing Video effects? by Eunuchswear · · Score: 1

      I don't have any real experience or hard data with [ the open source AMD and Nouveau ] drivers, because I've been fearful that working with these open source/reverse engineered drivers would have pissed off each vendor's closed source teams so much that they wouldn't help.

      Which is just fucking great.

      --
      Watch this Heartland Institute video
    28. Re:Problems causing Video effects? by __aaclcg7560 · · Score: 1

      I had a Radeon 7960 video card when I got ID Software's "Rage" for $2.50 during a Steam Black Friday sale a few years ago. The 7960 exceeded the minimum hardware specs for this game. The moment gameplay came up it chugged at 2FPS. New drivers, old drivers, hacked drivers. Nothing could make that game run. I recently got a Nvidia 720 video card and the game ran fine. Go figure.

    29. Re:Problems causing Video effects? by Coren22 · · Score: 1

      Your response was to a programmer telling you what problems there are in the gaming programming world, and you responded "I've build computers and that isn't how it worked". Did it ever occur to you that maybe the AC actually knows more about the subject than you? He used actual programming interface terminology, but maybe he's just blowing smoke up our rears and you know so much more about the subject because you plugged a few boards together and installed Windows.

      --
      APK likes to ask for responses to the same things over and over. Maybe he just likes the responses?
    30. Re: Problems causing Video effects? by MenThal · · Score: 1

      If it is on the stack and it had been destroyed, then you've popped that stack frame already... And can null it out.

      Hell, memset SP+1 up to the end of the memory available for your stack on each function, filling it with 0xdeadbeef... Hmm, that rings a bell.

    31. Re:Problems causing Video effects? by Whiteox · · Score: 1

      I don't get what you're on about. I respect the first AC's comment and I never disagreed with it. How could I? In fact, my followup comment tried to show what opinions are out there currently as far as driver issues and suspicions about game code, what a real system builder is up against when there is money to spare and you have clients who can afford it.
      I suppose it's easy to assume that 'I build gaming systems' equates to someone who whacks a few boards together and loads Windows and knows nothing about what they're doing. I do and I care and support my systems and clients.
      The 2nd AC was just rude.

      --
      Don't be apathetic. Procrastinate!
  3. Slashvertisment by Dunbal · · Score: 4, Insightful

    Why do I feel like this is an ad for the code analyzer?

    --
    Seven puppies were harmed during the making of this post.
    1. Re:Slashvertisment by TimSSG · · Score: 1

      Why do I feel like this is an ad for the code analyzer?

      Maybe, because it is one. Tim S.

    2. Re:Slashvertisment by TFlan91 · · Score: 2

      Let me quote:

      "This activity benefits everyone: readers enjoy learning from others' mistakes and discover new means to avoid them through certain coding techniques and style. For us, it's a way to have more people learn about our tool. As for the project authors, they too benefit by gaining an opportunity to fix some of the bugs."

      I added the bold.

    3. Re:Slashvertisment by turp182 · · Score: 4, Informative

      I believe you didn't read the link. It was written by PVS staff, and states very clearly that the effort was to promote their product:

      As a way of promoting our PVS-Studio static code analyzer, we've thought of an interesting format for our articles: We analyze open-source projects and write about the bugs we manage to find there.

      They made it to Slashdot, so the effort was a success on some level. And maybe more people need to be aware of code analyzers (we just enforce code conventions and obvious bad practices).

      --
      BlameBillCosby.com
    4. Re:Slashvertisment by UnknownSoldier · · Score: 1

      They have some good featured articles

      PVS-Studio: analyzing ReactOS's code
      http://www.viva64.com/en/a/007...

      Analysis of Godot Engine's Source Code
      http://www.viva64.com/en/b/032...

      Analyzing FreeCAD's Source Code and Its "Sick" Dependencies
      http://www.viva64.com/en/b/032...

    5. Re:Slashvertisment by UnknownSoldier · · Score: 1

      Considering there are tons of bugs in open source programs ... you might be right :-)

      Intel Galileo UEFI analysis (May 2015)
      Godot Engine analysis (April 2015)
      FreeCAD analysis (April 2015)
      Haiku OS analysis: part 1, part 2 (April 2015)
      Vim analysis (March 2015)
      CoreCLR analysis (March 2015)
      LibreOffice analysis (March 2015)
      MatrixSSL analysis (February 2015)
      Linux kernel analysis (January 2015)
      Powder Toy analysis (December 2014)
      Spring RTS analysis (December 2014)
      Miranda NG analysis: part 1, part 2 (November 2014)
      NSS analysis (October 2014)
      KDE analysis (September 2014)
      Oracle VM VirtualBox analysis: part 1, part 2 (September 2014)
      PHP analysis (September 2014)
      Asterisk analysis (August 2014)
      Cocos2d-x analysis (August 2014)
      GIMP analysis (August 2014)
      Wine analysis (August 2014)
      Bitcoin analysis (July 2014)
      OpenMW analysis (May 2014)
      Tesseract analysis (May 2014)
      TortoiseGit analysis (May 2014)
      WinSCP analysis (April 2014)
      Unreal Engine 4 analysis (April 2014)
      Microsoft Word 1.1a analysis (April 2014)
      Scilab analysis (March 2014)
      μManager analysis (March 2014)
      CryEngine 3 SDK analysis (March 2014)
      glibc analysis (February 2014)
      Firebird analysis (February 2014)
      LibRaw analysis (February 2014)
      Source SDK analysis (January 2014)
      PostgreSQL analysis (December 2013)
      Geant4 analysis (November 2013)
      VirtualDub analysis (October 2013)
      OpenMS analysis (September 2013)
      Boost analysis (August 2013)
      Multi Theft Auto analysis (August 2013)
      NetXMS analysis (May 2013)
      This one is not open-source, but still useful to everyone. C++Builder header files analysis (May 2013)
      Windows 8 Driver Samples analysis (April 2013)
      OpenCV analysis (March 2013)
      Casablanca analysis (March 2013)
      OpenSSL analysis (December 2012), second analysis (April 2014)
      Tor analysis (November 2012)
      This one is not open-source, but still useful to everyone. Visual C++ libraries analysis (September 2012), second analysis (October 2014)
      Trans-Proteomic Pipeline analysis (August 2012), second analysis (September 2013)
      MAME analysis (July 2012)
      Blender analysis (April 2012)
      Dolphin-emu analysis (February 2012)
      TrinityCore analysis (February 2012)
      Quake III Arena GPL analysis (February 2012)
      Firefox analysis (December 2011), second analysis (June 2014)
      Doom 3 analysis (November 2011)
      ReactOS analysis (September 2011), second analysis (April 2013)
      Clang analysis (August 2011), second analysis (August 2012)
      Intel Energy Analysiser SDK analysis (July 2011)
      Apache HTTP Server analysis (July 2011)
      Qt analysis (July 2011), second analysis (April 2014)
      Chromium analysis (May 2011), second analysis (October 2011), third analysis (August 2013), fourth analysis (December 2013)
      Miranda IM analysis (March 2011)
      Intel IPP Samples analysis (January 2011), second analysis (October 2011), third analysis (April 2012)
      Ultimate Toolbox analysis (December 2010)
      TortoiseSVN analysis (December 2010), second analysis (June 2013)
      qutIM analysis (November 2010)
      Fennec Media Project analysis (November 2010)
      Notepad++ analysis (November 2010), second analysis (February 2012)
      WinMerge analysis (October 2010), second analysis (March 2012)

    6. Re:Slashvertisment by UnknownSoldier · · Score: 4, Informative

      The one review everyone is interested in ... Linux Kernel (Jan 2015) static analysis!

      Other notable ones are:

      * LibreOffice
      * Vim
      * Gimp
      * Wine
      * Blender
      * Quake 3 Arena
      * Doom 3
      * Notepad++ (2012)

    7. Re:Slashvertisment by bitflip · · Score: 1

      It's an ad, but it's one of the better ones. It isn't all hype - they demonstrate the effectiveness of their product on code we all have access to.

      I learned a few things, too (I haven't touched c++ in awhile, so I guess that isn't a very high bar).

    8. Re:Slashvertisment by just+another+AC · · Score: 1

      I definitely didn't get that impression coming through my dell monitor, maybe it was due to the speed it loaded, thanks iinet, anyway I'm thirsty in a way only an ice cold coke can quench.

      Sent from windows laptop. ...Seriously everything is one giant marketing exercise nowadays.

    9. Re:Slashvertisment by Kjella · · Score: 1

      They made it to Slashdot, so the effort was a success on some level. And maybe more people need to be aware of code analyzers (we just enforce code conventions and obvious bad practices).

      Maybe you should stop enforcing obvious bad practices first? :)

      --
      Live today, because you never know what tomorrow brings
    10. Re:Slashvertisment by turp182 · · Score: 1

      We're actively working on that, specifically on older systems where habit is more common than good practice ("this is how we have always done it").

      --
      BlameBillCosby.com
    11. Re:Slashvertisment by jandrese · · Score: 1

      It kind of is, but they put in so much information that I can't hold it against them. Look how many code fragments with common errors there are in there. This is a quality article.

      --

      I read the internet for the articles.
    12. Re:Slashvertisment by Anonymous Coward · · Score: 0

      He was nitpicking your grammar.

    13. Re:Slashvertisment by Anonymous Coward · · Score: 1

      If PVS' code analyzer can help a developer find bugs that would either go unfound, or would take more $$$ than the cost of the code analyzer to find, then bravo to PVS for making a development tool that not only works, but is priced correctly based on the value it brings to the project.

      That PVS then joins an open source project and uses its code analyzer to help identify and fix bugs in the project, with the intent of that activity promoting their product I think is a good thing.

      PVS didn't have to do this, they did it voluntarily, with the hope of increasing awareness of their tool.

      More companies should do this. I remember a time when software companies willingly gave their product away to universities in the hopes that it would get used by the future grads, and then promoted to the companies hiring the grads from the inside.

      Marketing a good tool isn't a bad thing.

  4. It's an advertisement for their PVS Studio product by Anonymous Coward · · Score: 0

    An interesting read, but it really pushes their product hard. They did this to sell a product.

  5. What issues are they "fixing" by Anonymous Coward · · Score: 0

    What issues are they "fixing" - is it academic issues - coding style issues, or actual functional and performance issues.

    Where were the "issues" raised from - customers, third party developers or "in house"?

    1. Re:What issues are they "fixing" by Anonymous Coward · · Score: 1

      All this information and more can be yours for the low, low price of READ THE ARTICLE!!

    2. Re:What issues are they "fixing" by Headw1nd · · Score: 1

      I chuckled.

    3. Re:What issues are they "fixing" by edxwelch · · Score: 1

      Good question.
      If you go though the problems found - non of them are serious - they are error that could potentially cause problems, but don't actually. In general, static code analysis can only improve the code quality marginally.

    4. Re:What issues are they "fixing" by Ihlosi · · Score: 1
      In general, static code analysis can only improve the code quality marginally.

      Finding a potential problem through static code analysis and fixing it before the release is usually much cheaper than finding the problem in the wild, tracking down the bug, fixing it, and patching everything that's out there.

    5. Re:What issues are they "fixing" by edxwelch · · Score: 1

      I agree.
      I did not say you should not use it, just that the type of problems found by static analysis are minor

  6. PVS Studio is for Luddites. by Anonymous Coward · · Score: 0, Funny

    Modern app appers app app apps using app apps!

    Apps!

  7. Re: It's an advertisement for their PVS Studio pro by donscarletti · · Score: 2

    It does make a good case for their product. I look at most of that stuff and think "I have done that" and think how much time has been wasted diagnosing such bugs.

    However, what concerns me is the potential noise that is not in the article. I am pretty sure there are a few things that it reports that are actually OK and these things weren't included. Though I admit that I don't know for certain this is the case.

    --
    When Argumentum ad Hominem falls short, try Argumentum ad Matrem
  8. ok how much does it cost? by Anonymous Coward · · Score: 0

    call us to find out.. .Ok so that means it is at least 10k per year per seat.

  9. Wow, one mature reaction among the usual knee-jerk by Anonymous Coward · · Score: 0

    Normally when someone approaches a company, they are treated like some kind of demonic enemy. This should be the model case to point to - let's work together. So what if its equivalent to "hire me".
    Ah, but its a gaming software company, not some clothing / gadget marketplace multinational, and they did post all their code publicly - sigh, was a nice concept.

  10. Re: It's an advertisement for their PVS Studio pro by Anonymous Coward · · Score: 0

    It's almost certain that a static code analyser will miss things, or mark false positives. There is usually a way to tell the analyser, "no, this is correct, please don't report it" - but IMO, usually it's a sign that the code should be restructured slightly to avoid confusion (because if the analyser is confused, there's a fair chance a human will be too.)

    It's like any tool: there's an initial hurdle of getting things set up to use it effectively (source code repositories, for example), but the benefits in the long run usually far outweigh that initial effort.

  11. They didn't fix everything, maybe even added a few by Anonymous Coward · · Score: 0

    For example, they changed some code to this:

    float SGammaUIPanel::OnGetGamma() const
    {
    return GEngine ? GEngine->DisplayGamma : 2.2f;
    }

    Which should have triggered their own warning: PVS-Studio: V522 Dereferencing of the null pointer 'GEngine' might take place. It should, instead, have been changed to this:

    float SGammaUIPanel::OnGetGamma() const
    {
    return (GEngine != null) ? GEngine->DisplayGamma : 2.2f;
    }

  12. Neat, but over a year old.. by XaXXon · · Score: 1

    This isn't exactly timely.. this happened march 2014.

  13. Looks like they're avoiding parentheses ... by Ihlosi · · Score: 1
    ... in the code at all costs to make it look pretty, and, hey, everyone's supposed to know the operator precedence rules. Which promptly come and bite them in the rear, see the "suspicious sum" paragraph.

    I can see why one of the MISRA rules states that "limited dependence" should be placed on C operator precedence and expressions should be clarified (to the reader, not to the compiler) by using parentheses.

  14. What's news? by skovnymfe · · Score: 1

    Company releases product as open source project. Other company submits code to open source project. Why is this even news?

  15. "Excess variable declaration" by Anonymous Coward · · Score: 0

    I suspect his suspicion is false, ResolveRedirects might be a function that's relatively expensive to call and seldomly has to be called. Then it makes no sense for that function to always be called instead of the probably cheaper FindRef first.

  16. Biggest benefit of static analysis is real time by IamTheRealMike · · Score: 1

    The problem with articles like this one is that they tend to under-represent the benefits of static analysis. Products like PVS-Studio are designed to work with C++ and because they have to run in a big compile job, they get run in batch at the end of each day.

    This is a problem because (a) C++ is very hard to statically analyse so performance is often poor and (b) the most critical time when you need/want static analysis feedback is when you're actually writing the code itself.

    So let me insert a plug here for IntelliJ IDEA by JetBrains. Up until I used this (free, open source) program I didn't really appreciate static analysis. I mean, I appreciated it in a theoretical way, but my experience was that running it tends to generate thousands of spurious warnings that rarely reveal serious bugs. But that was because by the time the analysis got to run it was on code that had long since crashed in production, been debugged, unit tested, etc. So there was little meat left to harvest.

    IntelliJ has a thing called the Inspector, which runs constantly in the background on spare CPU cores. It scans for hundreds of different kinds of bugs and when it spots one it highlights the bogus code in yellow, right in the editor. What impressed me most about this is that often the editor can highlight very complex bugs within seconds of you writing them, long before any time has been spent on unit testing or in a debugger. It can do this partly because the languages the inspector supports (things like Java, Kotlin, Scala etc) are much easier to parse and analyse than C++. You don't need to invoke a full blown compiler. Also the use of annotations to give the analysers more information is widespread.

    But the best thing about IntelliJ is that when it does find a bug (and it frequently does), you can just press a hotkey and get a menu that lets you either suppress the warning ....... or automatically fix it, right there in the editor! So not only does IntelliJ find brainfarts like writing an if statement that will always yield true, but it can do it in real time and then it can often even fix it for you! This video I recorded a while ago shows a few seconds of this feature in action.

  17. Re:Wow, one mature reaction among the usual knee-j by EmagGeek · · Score: 1

    That is not workable in practice on a large scale, because it would involve admitting to a defect in a product. If that defect were to cause some actionable tort, the admission would be used to wring the company dry.

  18. Re:They didn't fix everything, maybe even added a by Anonymous Coward · · Score: 0

    Do you know C at all?

  19. Re:They didn't fix everything, maybe even added a by Anonymous Coward · · Score: 0

    Did you RTFA at all? A previous example on the same page threw V522 warnings from a similar construct.

  20. Re:They didn't fix everything, maybe even added a by Ihlosi · · Score: 1
    Did you RTFA at all? A previous example on the same page threw V522 warnings from a similar construct.

    The construct is similar, but not identical. The difference is significant, though.

  21. Re:They didn't fix everything, maybe even added a by Ihlosi · · Score: 1
    Which should have triggered their own warning: PVS-Studio: V522 Dereferencing of the null pointer 'GEngine' might take place.

    Please explain under which condition(s) the code

    return GEngine ? GEngine->DisplayGamma : 2.2f;

    will dereference a null pointer.