Finding Bugs Is Easy 66
daveho writes "My advisor and I are working on a tool to automatically find bugs in Java programs. One of the interesting results of our work is that we've found hundreds of real bugs in production code using extremely simple techniques. We believe that automated tools, if used more widely, could prevent a lot of bugs from making it in to production systems."
So (Score:1)
Prebugging (Score:1)
what did you use when debugging this program?
The most productive debugging happens in the design phase. Keeping each independent module small, simple, and focused, makes it harder to make a mistake.
Looks really kewl. (Score:5, Interesting)
At first I was frustrated that it needs a jar file. On my hard drive my code is just sitting in directories. So I made a jar file out of my code just for this program.
Then I was frustrated that the GUI wouldn't show me the source, but then I realized that I had compiled without debugging information in my classes (no line numbers and such). I recompiled and remade the jar file and it started showing me the source.
Most of the errors that it finds in my stuff aren't really errors. I get a lot of complaint about "should be declared package" when package is the default and I don't specify a modifier. I also get errors about ignored exceptions for things like this:
// This can't happen.
// The input and output streams were constructed
// on memory structures that don't actually use IO.
} catch (IOException x){
}
I think it may have found a few bugs though. Its complaining about at least one thing not being threadsafe. Also complaining about an inner class being static when it probably shouldn't be.
Now I want an Ant task for this so that I can make sure it runs on my code every time I compile. It is sort of like extended compiler warnings. Pretty helpful.
Re:Looks really kewl. (Score:3, Informative)
} catch(IOException x) {
assert(false);
}
I'm sure that would make the error go away.
Re:Looks really kewl. (Score:3, Insightful)
Uninitialized read of labels in constructor:
// setlocale inits labels
if (labels == null){
setLocale(Locale.getDefault());
}
Its complaining because I'm comparing it to null? I think its a bug in the analysis.
Of course, it would be nice if there were a document that would tell you how to manipulate your code to hide things that you have determined not to be errors from the analyzer. Maybe a list of errors that you have already looked at. Possibly comments you c
Re:Looks really kewl. (Score:3, Informative)
Re:Looks really kewl. (Score:2)
The fix is of course to remove the check. Then you don't read uninitialized memory.
Re:Looks really kewl. (Score:2)
Re:Looks really kewl. (Score:2)
Re:Looks really kewl. (Score:2)
Even though Java is *supposed* to initialize to null, there is no real guarantee that this will actually happen. Without explicit initialization to null, some JVM could just give you whatver data was in some register, which is more than likely *not* null. It's good that it's complaining, if that's the complaint.
Initial values of variables (Score:3, Informative)
wrong. The JavaTM Virtual Machine Specification - Second Edition [sun.com] says the following :
2.5.1 Initial Values of Variables
Every variable in a program must have a value before it is used:
Re:Initial values of variables (Score:2)
Re:Initial values of variables (Score:1)
well.. As the VM spec says otherwise, it's a bug. Elevating that bug to an exception/restriction makes no sense.
(Are you sure the variable was not initialized? or was it some Serialization-effect?)
Re:Initial values of variables (Score:1)
Though it may be a JVM bug, I need my code to work, so working around it does make sense.
Re:Initial values of variables (Score:1)
keeping your code work makes sense.
saying java variables aren't initialized not.
Re:Initial values of variables (Score:1)
Re:Looks really kewl. (Score:1)
Re:Looks really kewl. (Score:2)
If it really can't happen, why not this:
That way, if it really does happen, you'll find out about it.
Re:Looks really kewl. (Score:2)
I've never understood why if you have an exception that cannot happen anyone would ever want to ignore if it did. It makes no sense! You would want to know if it happened in the noisiest, loudest way! Some plonker will come along and change your code and the exception will then be able to occur.
Re:Looks really kewl. (Score:1)
Other rules of thumb for any programming language
Use the strictest compiler setting you can, and clean up any errors it finds
Don't do automatic type casting - heck, things like variants and auto type casting is what helped give VB a bad name in some circles - folks were screaming for strict casting back in VB4, and finally started to get in in VB.NET
I'd like to read more... (Score:1)
- From page:
- Presentation slides from Finding Bugs is Easy, invited talk, MASPLAS 2003
I get error 403 - permission error. I'll look at the other PDF later tonite I hope.Bugs in Java code? Inconceivable! (Score:3, Funny)
I thought it was impossible to write bugs in Java - nature's most perfect language! After all, all the Java bigo^H^H^H^Hzealot^H^H^H^H^H^Hexperts have always said that all software problems would vanish if we would just use their perfect language.
(/me removes tongue from cheek)
I just hope that the myriad and varied Java bigots out there will take this to heed: No language can prevent you from making mistakes.
(NOTE: I most emphatically do NOT assert that a language cannot make certain classes of errors more difficult to make!)
(NOTE 2: I also do not assert that all people who use Java, or promote the use of Java are bigots.)
There is no substitute for experience, careful design, and methodical testing.
Re:Bugs in Java code? Inconceivable! (Score:2)
Re:Bugs in Java code? Inconceivable! (Score:2)
Yup. While bounded arrays help remove certain classes of bugs, for example, the "null pointer exception" stepped in exactly where "segmentation fault" left.
The complexity of programming has been pretty constant since FORTRAN was adopted over assembler. "Object-oriented" removed some complexity but added its own, so the net gain is small. Maybe "aspects" will finally save us...maybe not.
Re:Bugs in Java code? Inconceivable! (Score:1)
I don't know... my programs have gotten much simpler since I started programming in Scheme. Except for having to write a lot of my own data structures. But thats no worse than C.
Re:Bugs in Java code? Inconceivable! (Score:2)
Man, there is no way I'd buy that. Ever see a copy of K&R sitting next to Stroustrup on the shelf?
Re: Inconceivable! (Score:2)
Now, the Java inventors were Sicilians; and everybody knows that you can't trust Sicilians... so you can't take the language that's before them! But... they would have expected you to know that, so you clearly can't take the language that's in front of you...
"You think that's good? Wait 'till I get going!" (-:
Re:Bugs in Java code? Inconceivable! (Score:1)
Assuming that it even existed, you can always make something that realizes a totally different task from the intended - that might be actually beneficial - I could use a teleporter for example. >:->
Damn straight it's easy to find bugs... (Score:1, Flamebait)
Okay low blow, but joking aside, what's newsworthy about this? Is there something that sets it apart from run-of-the-mill linters?
Reading UGH (Score:5, Interesting)
Re:Reading UGH (Score:2, Insightful)
in favor of autopsy (Score:2)
Re:in favor of autopsy (Score:1)
Re:in favor of autopsy (Score:1)
Would you rather have your text editor hit a bug and write random garbage over your term paper, or would you rather it just crash?
Re:in favor of autopsy (Score:1)
Re:in favor of autopsy (Score:1)
Huh? What makes you think that's an option, and how would it make any sense?
It writes corrupted data. You are not aware of this. You close the file. You open it again, maybe a few days later. You find out your hard work is hopelessly lost.
vs.
It crashes. You are immediately aware of this. You reopen the app and the file. Maybe you've lost back to the last time you saved, at most.
Bank analogy not flawed (Score:2, Insightful)
I don't know which side of the autopsy/physician debugging argument I'd sit on. I quite like Matlab's approach (which I believe is similar to Lisp's), in that you can choose to enter debug mode when an error occurs, and you can then interactively probe you code to find out why it ended up
...and? (Score:2)
Re:...and? (Score:5, Informative)
Javac and Jikes will tell you where it can't compile. This is higher level stuff like "such-and-such should be final" and "you have implemented equals but not hashcode." Code will run, and probably run fine, with these, but they may lead to subtle bugs difficult to track down. Compile-time or formatting bugs are easy to find. Bugs that express themselves in non-obvious ways are what we need more tools for.
In answer to another post, of course good design and good coding are best. This tool does not seek to replace thought, but push us towards proper coding
The obvious solution... (Score:4, Funny)
FindBugs? (Score:4, Funny)
They need to pick a name like "||gazm", "JizMop", or "Mozilla" like all the other cool OS projects. I'm sure they'll learn their lesson soon.
Re:FindBugs? (Score:3, Funny)
What a perfect name for a logic-based language or boolean calculator!
Re:FindBugs? (Score:3, Funny)
The Author really wanted to name it Firebird..... (Score:1)
History, repeat thyself. (Score:3, Insightful)
Automated tools like lint are an invaluable part of any software project and should be used at various points in a project's lifecycle. However, the bugs they find tend to be shallow (typecast problems, immediate memory violations, etc.). This is a certain improvement in software quality, but even Java programs can have side-effects from class to class that twist the mind of even the best programmer.
"Finding bugs is easy" makes sense in the context of my backyard but definitely not in programming.
Re:History, repeat thyself. (Score:3, Insightful)
Comment removed (Score:5, Informative)
Re:Been there, done that (Score:2, Informative)
Jlint (Score:4, Interesting)
Why not contribute to the existing, GPL, OpenSource, Java Lint? Why start a new project?
http://artho.com/jlint/
--MM
Re:Jlint (Score:2)
Re:Jlint (Score:1)
The real value (Score:3, Interesting)
And although it would be useful everywhere, I would think that a tool like this would fit nicely into an extreme programming shop, where the developers are already used to using automated tools on thier code.
Re:The real value (Score:2)
You have to have scripts that deduct from coding style the author of each part of the project, and then invokes the code-checking tool with the right options to catch the types of errors that particular programmer is likely to make, but not giving 1999 false positives for each real error.
Ok, I'm playing the devils advocate here, bu
Re:The real value (Score:3, Informative)
I was easily able to it up and running to test a 1000 class project that I've been working on for about two years now. It took all of 5 minutes from the time I read the article on slashdot to the point where I was fixing bugs that I had missed in two years of constant debugging, testing and refactoring. No scripts, no regular expressions, just point at the
Now, granted, they were some fairly simplistic bugs, and it's questionable whether or n
Re:The real value (Score:2)
Something else worth a look (Score:3)
Eclipse IDE (Score:1)
It's still mostly cleanup stuff, but it looks like they're moving towards having more of this stuff included by default. Currently you can set the error level (ignore, warning, error) when you do a build for unused imports/parameters/classes/methods/fields, circular dependancies, unreachable code, methods with constructor names, overridden methods that aren't package visible, hidden c
Suggestions to daveho (Score:2, Funny)
I got a few hints from the screenshots and changelist... but I need more!
* infrastructure for doing dataflow analysis
* tracking of locks for inconsistent synchronization detector
* a few general cleanup fixes in the screenshot
The first 2 especially sound interesting... but not quite enough for me to download a 0.5 version release and slog through the source code.
Halting (Score:3, Insightful)
Jason
ProfQuotes [profquotes.com]
Re:Halting (Score:1)
How did you solve the halting problem?
Some cases of the halting problem are straightforward to accept or reject.
Re:Halting (Score:3, Insightful)
Your statement is unnecessarily negative, unhelpful, and a bit silly.
PMD (Score:1)
detectors we have implemented, such as inconsistent
synchronization and mutable static fields, are not
present in PMD. Like our tool, PMD uses Visitors
to implement its pattern detectors. One nice
feature of PMD is that patterns may be implemented
as XPath expressions, so that new checks can be
added without the need to write a new Visitor
class...."
I'm wondering if they mean that their "detectors" (inconsistent synchronization and mutable static fields) can't be written in PMD XPath...
Ot