HNHacker News
TopNewBestAskShowJobs

AndreyKarpov

4,144 karma · joined February 11, 2011

Andrey Karpov. DevRel. Andrey Karpov is a co-founder of PVS-Studio — the company that is developing the PVS-Studio static code analyzer. The tool is designed for early detection of errors and potential vulnerabilities in C, C++, C#, and Java projects.

Andrey is the author of many publications devoted to writing quality C++ code.

Articles published in the company's blog: https://pvs-studio.com/en/blog/posts/?author=andrey-karpov

submissionscomments
AndreyKarpov··on Let's Play a Game – find bugs in popular open-source projects
Interesting idea. We can give error base ( http://www.viva64.com/en/examples/ ) for C++ (V501-V762) and C# (V3001-V3105) :)
AndreyKarpov··on Let's Play a Game – find bugs in popular open-source projects
Small comment. PVS-Studio is not Intel static analysis tool. It is OOO "Program Verification Systems": http://www.viva64.com/en/about/
AndreyKarpov··on Let's Play a Game – find bugs in popular open-source projects
You are optimist. If compilers were good, there would be the base of these errors: http://www.viva64.com/en/examples/

And Coverity is not perfect: http://www.viva64.com/en/b/0408/#ID0EGMAC

AndreyKarpov··on OpenJDK source code (C++) check by PVS-Studio tool
Yes.

Examples: http://www.viva64.com/en/b/0154/ , http://www.viva64.com/en/b/0360/

AndreyKarpov··on PVS-Studio: Static Code Analysis of UE4 (Part 2)
PVS-Studio: Static Code Analysis of UE4 (Part 1) - http://coconutlizard.co.uk/blog/ue4/pvs-studio-static-code-a...
AndreyKarpov··on PVS-Studio: Static Code Analysis of UE4 (Part 1)
Hello! I am one of PVS-Studio developers. Thanks a lot for the article, it’s great to see that you like the way the tool works.

It should be said, that you won’t probably find a lot of bugs in the code. The thing is, that once we have already delved in code of this project and fixed those bugs that were found (at that moment of course)

It all started with an article http://www.viva64.com/en/b/0249/

Later we worked cooperatively with Epic Games company and this work had the following results: http://www.viva64.com/en/b/0330/

Which means that at this moment you will be finding bugs that appeared after our fixes. But it’s not a big deal, we’ll be still very interested to see the articles you write. I just wanted to let you know about the previous articles.

Thank you once more, we are looking forward to reading Part II.

AndreyKarpov··on About size_t and ptrdiff_t
OMG! It is a great conspiracy theory! Everything is clear. Much time has elapsed since then, many people didn't read old articles about 64-bit. But these articles are useful and as we can see attract interest. Plus, the audience has changed. We would like to share with new one a good material. It is impossible to share old link that is why we decided republish some good articles in new places. This information will be interesting for recruits.
AndreyKarpov··on About size_t and ptrdiff_t
Why need a "ptrdiff_t" type:

1) http://www.viva64.com/en/l/0013/

2) http://www.viva64.com/en/b/0039/

AndreyKarpov··on Software bugs on Mars
I work at a company developing a static code analyzer to detect bugs in C/C++ software. As a means of popularizing the static analysis technology, we check various open-source projects for bugs and write articles about any issues we manage to find. Developers enjoy reading them very much as it’s always interesting to find out what mistakes have been made in this or that project by its authors.

Of course, we never mean to mock at project authors. We just show that no one is safe from making a typo and it won’t hurt if one takes some precautions against it. By means of real-life examples, we show how useful the static analysis methodology is. The list of our articles can be found here: http://www.viva64.com/en/a/0084/

People often suggest various projects for analysis. In particular, some of our readers have suggested trying to analyze the source codes of the James Webb Space Telescope or, even better, Mars rover autonomous driving system.

Indeed, let’s take a look at the list of cool C++ projects composed by Bjarne Stroustrup: http://www.stroustrup.com/applications.html

It turns out that C++ has already travelled to Mars (search through the list for the NASA keyword). And there is also a lecture CppCon 2014: Mark Maimone "C++ on Mars: Incorporating C++ into Mars Rover Flight Software" available on this topic: https://youtu.be/3SdSKZFoUa8

So we have grown highly enthusiastic about the idea of analyzing such interesting and safe software system as Mars rover flight software and probably finding at least a couple of bugs there. Well, the telescope is as interesting, too.

The hardest thing is how and where to get these source files, or at least their analogues. I guess no one will give us the source codes for the working spacecraft. But what if we could get the source codes of the older software versions or for spacecraft no longer in use?

This is why I am addressing the community. If anyone happens to know, please tell us whom we can contact to discuss this question. It won’t make any sense simply writing an email to NASA, will it? And there may be someone in this community who is directly involved in this area or knows someone who is. I will appreciate any information, contacts, and help you can offer. I’m sure it could bring us some interesting materials if it worked out. You can leave your comments right here or contact us at the following link: http://www.viva64.com/en/about-feedback/

P.S. I know about github.com/nasa. But there is nothing interesting in C/C++.

AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
Therac-25: https://en.wikipedia.org/wiki/Therac-25
AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
Yes, static analyzers mostly catch simple bugs. But it doesn't really matter if a bug is simple or complicated. You see, programmers believe they never make or make very few simple bugs: http://www.viva64.com/en/b/0116/

But they are wrong. They do make quite a lot of them. Here's, for instance, a bug database we have collected and keep updating: http://www.viva64.com/en/examples/.

Moreover, some bugs can take quite a while to find, despite being simple. Here's a nice example:

The conclusion is: the bug we had wasted about 50 hours to track was detected at once with the first run of the analyzer and fixed in less than an hour! Source: http://www.viva64.com/en/b/0221/

True, false positives aren't good, but they are not that much trouble. Static analysis tools provide numbers of means to suppress them. At least, we in PVS-Studio do have a lot of false positive suppression mechanisms. But it's a long story, so you'd better refer to the documentation.

AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
Parallel Reddit discussion: https://www.reddit.com/r/programming/comments/3b67pi/why_don...
AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
I would like to put my two cents.

1) PVS-Studio can instead be set to run in background immediately after the edited code has been successfully compiled.

2) PVS-Studio integrates with IncrediBuild. And soon we will publish an article about it. A little spoiler. :)

AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
Also, I recommend you to try Incremental analysis mode in PVS-Studio. It corrects on its own and doesn't distract programmer. http://www.viva64.com/en/b/0305/#ID0ECLDK
AndreyKarpov··on Why Don't Software Developers Use Static Analysis Tools to Find Bugs?
It is simply a conspiracy theory :-) PVS-Studio team doesn't belong to the article somehow. However, we knew about it and took into account.
AndreyKarpov··on C++ Tail Recursion Using 64-bit Variables
Part N2: http://www.viva64.com/en/b/0333/
AndreyKarpov··on Unreal Engine code issues are fixed by the third-party company
Link: https://www.unrealengine.com/blog/how-pvs-studio-team-improv...

Reddit discussion: http://www.reddit.com/r/programming/comments/3aehq5/unreal_e...

AndreyKarpov··on 200 Open Source Projects Later: Source Code Static Analysis Experience
The PVS-Studio analyzer is a methodology of detecting errors in program code. However, error is not an incorrect work of the program but also a potential vulnerability. Everything depends on perspectives you look at this errors.

That is why we took part in this forum and tried to demonstrate how often programmers make mistakes or make it vulnerable without any suspicions. The report is based on checking more than 200 projects experience. We were finding various defects with the help of PVS-Studio.

Here we suggest you to acquaint with our report:

- English version of presentation : http://www.slideshare.net/Andrey_Karpov/200-open-sourceproje...

- Russian version of presentation : http://www.slideshare.net/Andrey_Karpov/200-open-sourceproje...

- The record of Russian version of presentation with English submits: http://www.phdays.ru/broadcast/ . The report's start: 06:13:21. You can easily find it by number 200 on the page and choosing this report in the list.

AndreyKarpov··on 25 Suspicious Code Fragments in CoreCLR
And another more verified projects: http://www.viva64.com/en/a/0084/ :)
AndreyKarpov··on John Carmack: Static Code Analysis
Note. This article was originally published at the AltDevBlogADay site. But unfortunately the site ceased to exist. For more than a year, the article has been unavailable to readers. We contacted John Carmack and asked him if he minded us publishing that article at our site. He didn't and now we are glad to do this. To see the original article, use Wayback Machine - Internet Archive: http://web.archive.org/web/20120422160515/http://altdevbloga...
AndreyKarpov··on LibreOffice Project's Check
http://cgit.freedesktop.org/libreoffice/core/commit/?id=a598...
AndreyKarpov··on LibreOffice Project's Check
The GetType() is const function for simple return type:

    class SbiSymDef {
      ....
      SbxDataType GetType() const { return eType; }
      ....
    };
AndreyKarpov··on LibreOffice Project's Check
Call free(NULL); does not lead to any trouble. However, if you say that regularly use such statmen in your code, I'll be surprised. Analyzer surprised too. PVS suspects that it is not okay, and maybe we're dealing with some kind of typo or something else.
AndreyKarpov··on LibreOffice Project's Check
Readers' FAQ on Articles about PVS-Studio and CppCat: http://www.viva64.com/en/a/0085/
AndreyKarpov··on Rules for Developing Safety Critical Code [pdf]
Updatable List of Open-Source Projects Checked with PVS-Studio: http://www.viva64.com/en/a/0084/
AndreyKarpov··on Miranda NG Project to Get the “Wild Pointers” Award (Part 1)
Continue: Miranda NG Project to Get the "Wild Pointers" Award (Part 2) http://www.viva64.com/en/b/0292/
AndreyKarpov··on Three Interviews About Static Code Analyzers
A Bonus to the "Three Interviews About Static Analyzers" Article, or Interview Four: http://www.viva64.com/en/b/0285/
AndreyKarpov··on Can Static Analysis Replace Code Reviews?
The authors of the PVS-Studio analyzer invite you to test your attentiveness: http://www.viva64.com/en/b/0280/ :)

Code analyzers never get tired and can find errors a human's eye cannot easily notice. We have picked a few code fragments with errors revealed by PVS-Studio, all the fragments taken from well-known open-source projects.

AndreyKarpov··on C++ Quiz
First must selected. See description.

Let's simplify the code to make the error more obvious:

         if (a & Min_Max) { Min[0] Min[1] }
    else if (a & Max_Min) { Max[0] Min[1] }
    else if (a & Max_Max) { Max[0] Max[1] }
    else if (a & Min_Max) { Min[0] Max[1] }
It should be evident now that every line except the first one contains the correlation between names of constants and names of arrays. So, in the first expression the 'sC0Min1Min' should have been used instead.
AndreyKarpov··on Can We Trust the Libraries We Use?
The PVS-Studio team also does a great job: http://www.viva64.com/en/a/0084/
← PreviousPage 3 of 5Next →