PVS-Studio Analyzer Spots 40 Bugs In the FreeBSD Kernel
Andrey_Karpov writes: Svyatoslav Razmyslov from PVS-Studio Team published an article on the check of the FreeBSD kernel. PVS-Studio developers are known for analyzing various projects to show the abilities of their product, and do some advertisement, of course. Perhaps, this is one of the most acceptable and useful ways of promoting a proprietary application. They have already checked more than 200 projects and detected 9355 bugs. At least that's the number of bugs in the error base of their company.
So now it was FreeBSD kernel's turn. The source code was taken from GitHub 'master' branch. Svyatoslav states that PVS-Studio detected more than 1000 suspicious code fragments that are most likely bugs or inaccurate code. He described 40 of them in the article. The list of warnings was given to the FreeBSD developer team and they have already started editing the code.
A couple of words for programmers who are still not familiar with PVS-Studio. PVS-Studio is a tool for bug detection in the source code of programs, written in C, C++ and C#. It performs static code analysis and generates a report that helps a programmer find and fix the errors in the code. You can see a more detailed description of the tool on the company website and download a trial version.
So now it was FreeBSD kernel's turn. The source code was taken from GitHub 'master' branch. Svyatoslav states that PVS-Studio detected more than 1000 suspicious code fragments that are most likely bugs or inaccurate code. He described 40 of them in the article. The list of warnings was given to the FreeBSD developer team and they have already started editing the code.
A couple of words for programmers who are still not familiar with PVS-Studio. PVS-Studio is a tool for bug detection in the source code of programs, written in C, C++ and C#. It performs static code analysis and generates a report that helps a programmer find and fix the errors in the code. You can see a more detailed description of the tool on the company website and download a trial version.
you're looking at spending about $5k for the product, unless you are a large development team, cost benefit ratio is low
It's not a typo if you understood the meaning!
The lead one is amazing and worth the click. It has everything I hate: curly braces on same line, curly braces left out (which is usually a direct result of having curly braces on the same line- no visual distinction), goddamned tab characters, and of course, an if statement without braces so it conditionally runs only the next expression, followed by an expression that looks (by formatting) like it is also conditional, when in fact it is unconditional.
It's not all that good, but that's solid and made my blood boil.
Andrey_Karpov sure likes "their" company which he's totally not affiliated with.
I'm as happy as anyone about the higher frequency of technical content being posted recently, but not stuff like this. It smelled self-serving as soon as "this is one of the most acceptable and useful ways of promoting a proprietary application".
How many static code analyzers do we need? It must be really boring in Russia.
Have they checked systemd? What were their findings if they have?
It seems like every time they do this for promotion they just claim everything as a "bug" without really individually investigating and reporting all of them, taking only some obviously wrong ones and then lumping the whole report onto the project's bug tracker, if we're lucky.
PVS Studio is a great application but since they only do team licensing "1-9 developers" I can't see the benefit in buying it, just like IDA Pro. I'm an open source only dev in the C/C++/C# world, all my profitable work is in other languages...
I'd gladly pay a REASONABLE price for all these tools if they'd not only provide proper Linux versions (PVS studio only ever had an internal Linux version...in projects with Linux and Windows specific code it is difficult if not impossible to analyze the Linux parts) but so far since it seems like the real benefit to open source teams who can't afford this software (that is windows only anyway, mostly) is extremely low despite it's utility otherwise.
We would fire anyone who wrote code in the way kernel devs write code. Minimal comments, shitty variable names, shitty function names, ternary shit all over the place... Ugh. No wonder there are bugs.
How the fuck are you so sure that the code in question is "working as intended"?
For MOD_LOAD, random_source_register(&random_nehemiah) is only called under very specific circumstances.
Yet for MOD_UNLOAD, random_source_deregister(&random_nehemiah) is called even if random_source_register(&random_nehemiah) wasn't called during MOD_LOAD.
Deregistering something that was not registered properly in the first place is often a very dangerous, and incorrect, thing to be doing!
Oh, and guess what? A FIX WAS JUST FUCKING COMMITTED FOR THE BUG THAT YOU INCORRECTLY CLAIMED DIDN'T EXIST!
You should apologize to all of us for your snide, and incorrect, bullshit.
PVS-Studio detected more than 1000 suspicious code fragments that are most likely bugs or inaccurate code.
It must have been something you assimilated. . . .
None of the thirty checks that I just read about it are checks for bugs. They are all checks for untested code.
Every one of those "problems" -- and they are almost all simple mis-types -- are easily spotted by the very first time the developer tests that line of code.
Ultimately, I'm sure it's a very valuable tool for a company with developers who never test the code that they write.
On the other hand, since I test every line of code that I write, often as I'm writing it, it can't possibly test the bugs that I wind up producing -- which are all interactive bugs across features.
Of course, I ain't in C.
Glad to see the commercial world saving you guys again.
No the tab thing, he's likely correct on.
if (something is there)
tab1 dinit the something
tab2 close the something
It does look like those two things are supposed to be executed in the if. The close presumably tests the handle and rejects it, so it doesn't fail, but it does need fixed.
On the macro thing, they pass in 10, or 0 to that macro and it ignores it and uses 0. But so what, thats just cleanup if you get time.
It's all very meh! Each change carries a risk, I've seen some of the most obscure bugs introduced by well meaning code cleanups!
That's a job for J.C. and the Pussy Cats. While kids are jailed on those Pewdeepie videos (not googling the name of this idiot, because names like that are intended to be googled) instead of watching IDK... CrashCourse. The fault is on the lack of stars on the sky. Bats use stars to navigate, then how they will know where are places they had been before, where the good mosquitoEs are? How can I get an army of NERDS (level needed to fix OS bugs - Level 1 is Pascal/BASIC noobs, level 2 are C ninjas, and level NERDS is *&$WSXCVGBYHU(O)POKML*&ITR%$#TQ@Awzxcdf*&t*(y(upjiik&tu, about programing, got it?). I need go to Russia. God... They have a day just for the coders... (probably they kill a random developer as a celebration, IDK). Ah, to find out a good knight of the round, just look if it has the eyes of a tired person, with a smile of an winner.
you're looking at spending about $5k for the product, unless you are a large development team, cost benefit ratio is low
Why? One month of developer time is one month of developer time regardless of the size of the team. Either the product saves that much or more or it does not. If it does it is worthwhile.
As for whether a developer can afford the cost that again is not the function of the team size, rather the popularity of the dev team's product, the number of users. With a sufficiently sized market the revenue or donations would cover the cost regardless of the size of the team.
There are variables corrupted because operator precedence was misunderstood.
One of my favorite (not) type of bugs. Because a "two character comment", a pair of parenthesis, would just be awful. Two character to document your intent, which hopefully matches your implementation, but if not may just save you.
Maybe they should have gone where the smoke is and ran glibc through this.
There are quite a number of tools in this space: Coverity (pay-ware unless you qualify), lint, splint or my personal favorite on Windows: Cppcheck
Somebody get this to Bethesda, stat!
BitZtream was wrong. A fix has been committed which adds the missing parenthesis.
Developers! Developers! Developers! Developers!
https://www.youtube.com/watch?v=rRm0NDo1CiY
Aw, c'mon moderators. I posted this as a parody of the infamous *BSD is dying troll to be funny. Have a sense of humor, please.
Or perhaps during debugging, it was copied, experimental changes were made on one execution path (perhaps just a debug statement), then it was decided the changes weren't all that helpful, and the changes were deleted again, leaving both blocks identical (considered mostly harmless, but ought to have a comment if deliberately left that way).
You didn't use the joke tags
Is there a similar tool for java? so that I can check my project.
You would think that with all their bug hunting, they would actually bother to fix the english on their site. I know it's a pro tool, but jesus fucking christ I'm not going to recommend to anyone a site that seems like it is the output of google fucking translate.
It isn't the tabs, its that it appears from the code to be
if (something)
{
deinitialize the something
close the something
}
He talks about the tabs indicating perhaps the guy missed the brackets, but its not a style guide thing it looks like an actual bug.
you're looking at spending about $5k for the product, unless you are a large development team, cost benefit ratio is low
Geez, your developers must work really cheap. $5K is a few days of work for one dev. Including overhead, $200/hr or $2,000/day are good seat-of-the-pants numbers to use for the cost of a developer.
If this tool finds two bugs in your code base it pays for itself.
Would you pay someone to build your house if the only tools they used were a small hand saw and a 12-oz hammer? Or would you rather pay a professional who uses modern power tools that make the construction more COST EFFICIENT?
The submitter, Andrey Karpov, is one of the developers of PVS-Studio. The article he's plugging was written by yet another PVS-Studio developer. I wouldn't be in the least surprised if this got voted to the front page by an army of PVS-Studio sockpuppets. They've been doing the same thing on Wikipedia for years (though their site was long ago put on a Wikimedia-wide spam blacklist), and also post similar spamvertisements, masquerading as "bug reports", to the issue trackers of prominent free software projects such as Mozilla.
Things like comparisons of two equal values, and confusing indentation errors? Hmm...
Please do linux, glibc, openssl, MariaDB, PostgreSQL, httpd, nginx, Chrome, Firefox, python, ruby and gcc next. Thanks.
You obviously didn't read the videos poll thread. 90% (that cared to respond) of /. doesn't want videos.
This isn't 1980, we can parse identifier names that are longer than 2-3 characters.
mfp, ia, ifa, osti, mp, ha, ccb, cpi, hba, sbp, qla_tx_tso
Holy hell, people, I think we can stand to be slightly more verbose. I hate diving into code like this.
Aww fuck, thanks to moderation hiding the original post, I saw the replies as linked below the youtube post above it. And it's not "moderators", because it only takes a single mod to go from 0 to -1.
Because these two blocks of code are not the same (spot the difference). Here is block 1:
static int ....)
.... // <=
....
qla_tx_tso(qla_host_t *ha, struct mbuf *mp,
{
if ((*tcp_opt != 0x01) || (*(tcp_opt + 1) != 0x01) ||
(*(tcp_opt + 2) != 0x08) || (*(tcp_opt + 2) != 10)) {
return -1;
}
}
Here is block 2:
static int ....)
....
....
qla_tx_tso(qla_host_t *ha, struct mbuf *mp,
{
if ((*tcp_opt != 0x01) || (*(tcp_opt + 1) != 0x01) ||
(*(tcp_opt + 2) != 0x08) || (*(tcp_opt + 3) != 10)) {
return -1;
}
}
P.S.: Slashdot's comment editor sucks ass.
Sounds familiar. Application Verifier + Gflags + WinDbg (all available for free in Windows SDKs) saved me many a time here.