Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Using Redundancies to Find Errors

timothy posted more than 11 years ago | from the the-error-is-right-around-here dept.

Programming 338

gsbarnes writes "Two Stanford researchers (Dawson Engler and Yichen Xie) have written a paper (pdf) showing that seemingly harmless redundant code is frequently a sign of not so harmless errors. Examples of redundant code: assigning a variable to itself, or dead code (code that is never reached). Some of their examples are obvious errors, some of them subtle. All are taken from a version of the Linux kernel (presumably they have already reported the bugs they found). Two interesting lessons: Apparently harmless mistakes often indicate serious troubles, so run lint and pay attention to its output. Also, in addition to its obvious practical uses, Linux provides a huge open codebase useful for researchers investigating questions about software engineering."

cancel ×

338 comments

Sorry! There are no comments related to the filter you selected.

the mothers and the widows (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141187)

"There's only one person who hugs the mothers and the widows, the wives and the kids upon the death of their loved one. Others hug but having committed the troops, I've got an additional responsibility to hug and that's me and I know what it's like." George W. Bush, Washington, D.C., Dec. 11, 2002.

First Post (-1, Offtopic)

Amsterdam Vallon (639622) | more than 11 years ago | (#5141190)

How's that for redundant?

Finally (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141196)

It's been more than 3 hours since the last post. I was beginning to feel like a crack addict in need of shot.

Ahhhhhh. Thank you editors.

But around here... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141204)

The editors redundantly post stories, which is the error.
I'm taking bets we see this one again within the next 72 hours.

Wait a minute... (-1, Offtopic)

goatasaur (604450) | more than 11 years ago | (#5141208)

Is this how CmdrTaco finds errors in news articles?

Jesus... (0, Offtopic)

goatasaur (604450) | more than 11 years ago | (#5141217)

Modded down within 10 seconds of posting.

Slashdot is a harsh mistress. :(

Re:Jesus... (0, Offtopic)

c0wh (445032) | more than 11 years ago | (#5141260)

I think if the post constains the string "cmdrtaco," it's automatically downmodded.

Let's see!

peace in the world (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141209)

"The goals for this country are peace in the world. And the goals for this country are a compassionate American for every single citizen. That compassion is found in the hearts and souls of the American citizens." George W. Bush, Washington, D.C., Dec. 19, 2002

Re:peace in the world (-1)

Anonymous Coward | more than 11 years ago | (#5141264)

Peace in the world in the heart of every American citizen? That's a lie. I'm an American citizen, and I probably speak for many others when I say that I'd seriously love to see the middle east attacked, with some our heavy nuclear weapons. Leave no one alive, nothing standing. Just wipe it clean. That quote is hardcore bullshit. I won't deny it. Many Americans would love to see these asshole "rebel" countries nuked. Seriously woud brighten my day. We've got thousands of nuclear weapons - why not put them to use on our enemies?

Kaboom.

Re:peace in the world (-1)

Anonymous Coward | more than 11 years ago | (#5141375)

you are a fascist, which is typical of the USA mentality now. Pathetic luser, your country will be fucked by the end of this war, from your own doing.

Re:peace in the world (-1)

Anonymous Coward | more than 11 years ago | (#5141398)

Yea, um... that's a negative there, Ghostrider. If the USA ever came to a point where they knew they were losing a war, they'd definitely bust out the nukes. And, um, seeing as how they have the largest arsenal of nukes, and also have them deployed in other countries around the world, ready for use, I doubt the US is going to be "fucked by the end of the war". You see, now that the nuclear age is here, any country with a huge, usable stock of nukes will never be taken over. This is a whole new era. The nuclear era. When a nuclear superpower like the US is on its last legs, it hits the big red button labeled "NUKE" and makes the opposing countries vanish into thin air.

Isn't it grand being a nuclear superpower? Niggaz can't fuck with this. :)

I have no idea what this article means ! (1, Insightful)

red-beard's (639520) | more than 11 years ago | (#5141210)

NO flame intended i just have no clue as to the point of this . What exactly do these flaws cause and etc.. Maybe I'm just not l33t enough but i could sure use an explanation from someone more learned than me .

A good editor... (3, Funny)

yintercept (517362) | more than 11 years ago | (#5141315)

A good editor could easily cut that article in half without loss of any information.

Re:A good editor... (-1, Offtopic)

yourmom16 (618766) | more than 11 years ago | (#5141344)

he used redundancies to help him find errors in the article

vi! (4, Funny)

gregstoll (90319) | more than 11 years ago | (#5141500)

vi could do it!

Re:I have no idea what this article means ! (4, Insightful)

The Bungi (221687) | more than 11 years ago | (#5141332)

In any large system there's bound to be some amount of redundant code that can sometimes cause subtle errors, like slow memory leaks. These conditions develop over the lifetime of the code. Analyzing the code *as a whole* provides information about these types of situations and how to fix them, which more often than not is not trivial.

"Dead" or unreachable code is almost always caused by patches or fixes to an existing codebase and it's always good to detect and get rid of it because it may point to other problems in the application (in my experience), or is simply dead wood that should be removed.

Re:I have no idea what this article means ! (2, Insightful)

RollingThunder (88952) | more than 11 years ago | (#5141371)

And moreover, in the areas where you find these mechanically detectable bugs, the likelihood of more subtle bugs is higher, as these errors are made when the programmer isn't really thinking about what he's doing. It's like triaging your wounded code, to fix the worst first.

Re:I have no idea what this article means ! (3, Informative)

Anonymous Coward | more than 11 years ago | (#5141378)

Well let me summerize it for you:

That paper explored the hypothesis that redundancies, like type erros, flag higher-level correctness mistakes. They evaluated the approach using four checkers which they applied to the Linux operating system. These simple analyses found many superising (to them) error types. Further, those errors correlated well with known hard errors: redundancies seemed to flag confused or poor programmers who were prone to other error types. According to them, these indicators could be used to decide where to audit a system.

Re:I have no idea what this article means ! (-1)

Anonymous Coward | more than 11 years ago | (#5141401)

So these errors are confined to only programmers who are poor (in other words OpenSource programmers) right? Why would these errors not be found among paid programmers (Such as those from great software houses like Borland GmBH and Microsoft Software) ?

This is pretty good analsyis, based on this we should re-evaluate our understanding of opensource coding, and marxism. Here me out... You see, opensource advocates a world where you do not get rewarded (money wise), for your programming, rather they gurantee a satisifcation due to helping out others and feeding your ego into your id.

So, in this regard, the current convention of opensource projects should all fall under this remarkable and certainly historical paper. No towers of babble or catherdials or bazzars can stand in front of such acute and proper analysis of a problem that has eludeded our common thoughts for some time now.

There, I suggest to the hopeless...

Abandon all hope!! We are doomed.

Ok sorry about the spelling I'd diskliskisk.

Here's a text link (4, Informative)

Anonymous Coward | more than 11 years ago | (#5141214)

PDF usually crashes my computer (crappy adobe software). So here's a convenient text link!

http://216.239.37.100/search?q=cache:yuZKW8CjTqIC: www.stanford.edu/~engler/p401-xie.ps+&hl=en&ie=UTF -8 [216.239.37.100]

PDF usually crashes my computer (1, Funny)

Anonymous Coward | more than 11 years ago | (#5141354)

Maybe PDF has too much redundant code.

More details / PostScript version (2, Informative)

Amsterdam Vallon (639622) | more than 11 years ago | (#5141216)

More details
Appeared in FSE 2002. Finds funny bugs by looking for redundant operations (dead code, unused assignments, etc.). From empirical measurements, code with such redundant errors is 50-100% more likely to have hard errors. Also describes how to check for redundancies to find holes in specifications.

Link to PostScript file for easy viewing/printing
File [stanford.edu]

Re:More details / PostScript version (0, Offtopic)

The Bungi (221687) | more than 11 years ago | (#5141225)

Don't you get tired of this obsessive karma whoring?

Re:More details / PostScript version (0, Offtopic)

Interrupting Cow (247048) | more than 11 years ago | (#5141253)

Reminding people about karma whoring is karma whoring ;-)

Re:More details / PostScript version (0, Offtopic)

The Bungi (221687) | more than 11 years ago | (#5141348)

Actually, according to the Omnipotent Moderation Gods On Duty Tonight - it's offtopic *grin*

Errors like... (3, Funny)

Anonymous Coward | more than 11 years ago | (#5141218)

This really old Slashdot logo [slashdot.org] still in use over on Team Slashdot's page [distributed.net] on distributed.net.

Patience! (5, Funny)

houseofmore (313324) | more than 11 years ago | (#5141220)

"...dead code (code that is never reached)"

Perhaps it's just shy!

Re:Patience! (0)

yourmom16 (618766) | more than 11 years ago | (#5141287)

"...dead code (code that is never reached)"

Perhaps it's just shy! or maybe it was taken straight out of BSD

html (2, Informative)

farnsworth (558449) | more than 11 years ago | (#5141228)

html version is here [216.239.53.100] .

Google cache (1)

Una (122314) | more than 11 years ago | (#5141232)

Dont even bother using the google cache of the pdf.
Its completely unreadable.

If you dont believe me, look for yourself:
here [216.239.37.100]

New slogan (1)

mentin (202456) | more than 11 years ago | (#5141233)

Given enough lints, all bugs are shallow!

Analysis "by file" vs "by function"? (0, Insightful)

mcdrewski42 (623680) | more than 11 years ago | (#5141234)

A file (module/unit/whatever) is still a fairly high granularity to make decisions upon. I'd be more interested at finding bugs within specific functions rather than just files...

redundant? (3, Interesting)

1nv4d3r (642775) | more than 11 years ago | (#5141236)

To me 'redundant' implies duplication of something already there. (a=1; a=1;)

a=a; and dead code aren't so much redundant as they are superfluous. It's still a sign of possible errors, for sure.

Re:redundant? (2, Insightful)

drzhivago (310144) | more than 11 years ago | (#5141309)

Rendundant code would be more akin to something like this:


if (a==1)
{
[some chunk of code]
}
else
{
[same (or almost exact) chunk of code]
}


where the same code block appears multiple times in a file/class/project. By having the same block of code appear multiple times the chance of a user-generated error increases. Easily fixed by moving the repeated code into a parameterized function.

Re:redundant? (1, Funny)

Anonymous Hack (637833) | more than 11 years ago | (#5141346)

a=a superfluous? HOW DARE YOU! a=a is the foundation from which everything else derives! a=a proves that the only logical course of action is to TAKE! a=a is the single, most important, non-patented discovery since the wheel!

Now, i'm off to create a new form of steel that will revolutionize the railroad industry!

Re:redundant? (4, Insightful)

Karl Hungus, nihilis (644003) | more than 11 years ago | (#5141355)

Steve McConnell in the excellent book Code Complete talks about this sort of stuff. One of the big things was unused variables. Completely harmless, but a good indication that the code may have problems. If whoever is maintaining the code didn't bother to remove useless variables, what else are they not bothering to take care of?

It's not, keep the code squeaky clean because cleanliness is next to godliness, it's keep the code clean so it's easy to read. Keep it clean because it's a discipline that will pay off when it's time to spot/fix the real errors in the code.

Re:redundant? (1)

Anonymous Hack (637833) | more than 11 years ago | (#5141356)

And, excuse me for replying again, but ALL GOOD CODE SHOULD HAVE AT LEAST ONE a=a; STATEMENT! Lest we forget our rational principles.

Re:redundant? (0)

Anonymous Coward | more than 11 years ago | (#5141499)

Ayn Rand would begin all code with 1=1. However, a true revolutionary would include an occasional

if (1==2)

to encapsulate the code of the oppressive bourgeoise he is fighting to supplant.

Re:redundant? (1)

Ambassador Kosh (18352) | more than 11 years ago | (#5141488)

a=a is used in some languages when you are working with an object persistence system to signify a change to a mutable object so that it gets saved to the db. With ZODB for example if you make a change to a mutable object like a list, dictionary etc you can assign the object back to itself and the persistence system will save that object or you could do self._p_changed=1. Other OODB systems have similar types of persistence signaling.

Porky (0)

Anonymous Coward | more than 11 years ago | (#5141239)

The redundancy checker would have a field day in code written by Porky the Pig. ...th..th..tha..that's all folks...

Is this not Obvious (1, Flamebait)

goombah99 (560566) | more than 11 years ago | (#5141245)

so run lint and pay attention to its output.

pardon me, but DUH???

Re:Is this not Obvious (5, Informative)

gmack (197796) | more than 11 years ago | (#5141420)

If only the story poster had actually read the paper.

They used a custom checker that finds these things much more effiectivly than lint.

I actually remember the flood of bug reports and kernel patches that toy of theirs generated the first few months they put it to use on the kernel.

How to Avoid Mistakes? Practical Advice? (4, Insightful)

webword (82711) | more than 11 years ago | (#5141247)

Unfortunately, this paper doesn't really offer any practical advice. Is is probably a little useful to very good, or great programmers. However, for new or moderately good programmers, it probably won't be very useful. It is certainly interesting in the academic sense, but I always want to see more practical advice. (I suppose that good practical advice flows down from good theoretical advice.)

What are some of the best ways to learn to avoid problems? I know that experience is useful. Trial and error is good, mentoring is good, education is good. What else can you think of? What books are useful?

Also, I wonder about usability problems. In other words, this article mainly hits on the problems of "hidden" code, not the interface. I'd like to see more about how programmers stuff interfaces with more and more useless crap, and how to avoid it. (Part of the answer is usability testing and gathering useful requirements, of course.) What do you think about this? How can we attack errors of omission and commission in interfaces?

Re:How to Avoid Mistakes? Practical Advice? (4, Insightful)

trance9 (10504) | more than 11 years ago | (#5141328)


I think the lesson here is basically that the compiler is your friend. Turn on all the error checking you possibly can in your development environment and pay attention to every last warning.

If there is something trivial causing a warning in your code--fix it so it doesn't warn, even though it wasn't a "bug". If your compiler output is always pristine, with no warnings, then when a warning shows up if it's a bug you'll notice.

Kind of common sense if you ask me--but maybe that's just a lesson I learned the hard way.

Re:How to Avoid Mistakes? Practical Advice? (4, Insightful)

Pseudonym (62607) | more than 11 years ago | (#5141372)

I'd put it more strongly than that. Reading between the lines of the paper, don't just fix the warning. Look around the place where the warning happened. You'll most likely find a bug.

It's also a call for compilers to generate more warnings, which can only be a good thing.

Re:How to Avoid Mistakes? Practical Advice? (2, Interesting)

Glass of Water (537481) | more than 11 years ago | (#5141381)

I think the lesson is just what they're saying. Applying these tests on a body of code is a good way to find high-level errors, even though the tests just check for low-level mistakes.

That seems pretty practical to me.

The issue you raise about interfaces is only tangentially related. There, you get in to the problem (a very real problem) of confusing coding. This paper does not deal with the issue of whether the code is written well from the point of view of other programmers who need to work with it.

Re:How to Avoid Mistakes? Practical Advice? (1)

MisterFancypants (615129) | more than 11 years ago | (#5141434)

What do you think about this? How can we attack errors of omission and commission in interfaces?

There are many products that do code coverage testing such as PureCoverage [rational.com] . Basically they analyze code as it is running and make note of which parts of your code have been executed and which haven't. This is very useful in making sure all possible code paths are tested, and if a code path isn't hit at all it gives you a good indication that you've got a 'dead' patch of code that you might want to look more closely at. Sadly such tools are generally very expensive.

Re:How to Avoid Mistakes? Practical Advice? (3, Insightful)

1nv4d3r (642775) | more than 11 years ago | (#5141456)

I'd like to see more about how programmers stuff interfaces with more and more useless crap, and how to avoid it.

Well, identifying it as useless crap is a good first step.

And for managers:

while(economy.isDown())
if(newInterface.isUselessCrap())
{
fireEmployee();
hireNextTelecomRefugee();
}

If you want a serious answer, one reason programs get filled with so much useless crap is because 80% of programmers program so they can collect a paycheck. They don't give a flying fuck if their code is good or not. That was a big eye-opener for me when I first got out of school. I couldn't believe how many people just didn't care.

If you are interested at all in not muddying the interface, you are most of the way there. Give it some thought, consult with your peers, and try to learn from mistakes.

Don't be afraid to refactor code every so often, because, schedule or no schedule, new requirements move the 'ideal' design away from what you drew up last month. That's (to my mind) the second largest contributor. Even good coders crumble to cost and schedule, and band-aid code that just plain needs to be rethought. In some environments, that's a fact of life. In others you will have to fight for it, but you can get code rewritten.

Good Design = Tight Code (5, Insightful)

chewtoy-11 (448560) | more than 11 years ago | (#5141249)

Writing repetitive code only once offers the same benefits as using Cascading Style Sheets for your webpages. If there is a serious error, you only have to track it down in the one place where it exists versus every single place you re-wrote the code. Also, it makes adding features much simpler as well. I'm an old school procedural programmer that is making the rocky transition to OOP programming. THIS is where it starts coming together...

And their other findings ... (5, Funny)

kruetz (642175) | more than 11 years ago | (#5141250)

They also found that:

Russian errors cause code
Incorrect code causes errors
Missing code causes errors
Untested code causes errors
Redundant codec causes redundancies
Driver code causes headaches
C code causes buffer overflows
Java code causes exceptions
Perl code causes illiteracy
Solaris code causes rashes
Novell code causes panic attacks
Slashdot code causes multiple reposts
Slashdot articles cause poor-quality posts
Microsoft code causes exploits
Apple code causes user cults
Uncommented code causes code rage
RIAA code causes computers to stop functioning
(Poor idea causes long, desperate post)

Re:And their other findings ... (1)

Hektor_Troy (262592) | more than 11 years ago | (#5141436)

NASA code causes expensive crashes

So... (1)

worst_name_ever (633374) | more than 11 years ago | (#5141254)

...bad programming causes problems? Golly! What will those crazy scientists come up with next?

Using redundant code to find errors (1)

Amsterdam Vallon (639622) | more than 11 years ago | (#5141256)

while(1)
findError();
while(1)
findError();
while(1)
findError();
while(1)
findError();


Your comment violated the "postercomment" compression filter. Try less whitespace and/or less repetition. Comment aborted.

Re:Using redundant code to find errors (2, Funny)

nebbian (564148) | more than 11 years ago | (#5141470)

I was going to moderate this but there's no +1 Redundant.

lint is horrible (3, Insightful)

Anonymous Hack (637833) | more than 11 years ago | (#5141259)

It really is. It's a redundant holdover from ye old BSD versions. Granted, there are one or two times i've used it when -Wall -pedantic -Werror -Wfor-fuck's-sake-find-my-bug-already doesn't work, but a lot of the time it comes up with a LOT of complaints that are really unnecessary. Am i really going to have to step through tens of thousands of lines of code castind the return of every void function to (void)? Come on.


Re:lint is horrible (0)

yourmom16 (618766) | more than 11 years ago | (#5141327)

void functions arent supposed to have a return value.

Re:lint is horrible (1)

AuMatar (183847) | more than 11 years ago | (#5141342)

Why the hell would a void function have a return to begin with?

Re:lint is horrible (1)

popeyethesailor (325796) | more than 11 years ago | (#5141402)

Perhaps he just ends with a return :)

Re:lint is horrible (1)

miu (626917) | more than 11 years ago | (#5141417)

I think the fellow was talking about casting the return of calls like printf, they return a value, but most of the time you are not interested in it.

Re:lint is horrible (3, Insightful)

Anonymous Hack (637833) | more than 11 years ago | (#5141421)

Lint? Lint compains if you call a function that returns an int and you ignore the int. This is particularly irritating in the case of strcpy() and similar functions where you would normally do:

strcpy(buf, "hello");

except you're supposed to do:

(void) strcpy(buf, "hello");

or...

buf = strcpy(buf, "hello");

And that's just the beginning...

Re:lint is horrible (4, Insightful)

RhettLivingston (544140) | more than 11 years ago | (#5141349)

I enforced a policy of eliminating all Lint info messages on a 1.5 million line, from scratch project. And, I do mean from scratch. we wrote our own operating system, ANSI c Library, and drivers and ran it on hardware that we designed and produced. In the first 2 years of deployment, only five bugs were reported. Lint was only part of the reason, but it was a total part.

Re:lint is horrible (1, Funny)

Anonymous Coward | more than 11 years ago | (#5141405)

Stop bragging, Linus.

Re:lint is horrible (0)

Anonymous Coward | more than 11 years ago | (#5141370)

Why the hell would a void function have a return to begin with?

I think he means casting the result, as in

(void) printf("hello, world\n");

Re:lint is horrible (0)

Interrupting Cow (247048) | more than 11 years ago | (#5141415)

Wow. I don't know where to start. Do you have any idea what you're talking about? Before you start let me answer, "No".


castind [sic] the return of every void function

Um, void functions don't return anything. A simple return will suffice.

Am i really going to have to step through tens of thousands of lines of code

Yes, if you have crap that is returning something in void functions.

If you want to know some of the things lint can look for that are perfectly legal code constructs look at this list. [ddj.com]

Compiling is not the same as error analysis.

Re:lint is horrible (1)

Anonymous Hack (637833) | more than 11 years ago | (#5141446)

Sorry i meant casting the return of a non-void function to void :-) Screwed up.

Re:lint is horrible (1)

hayne (545353) | more than 11 years ago | (#5141467)

castind the return of every void function

I suspect that he meant "of every non-void function". And I've done that sort of thing on a big project but also just gotten rid of such spurious complaints via grep -v on the log file. And I did find some functions where the return value was being ignored when it definitely shouldn't have been!

I Hope They Didn't Get Paid (1, Flamebait)

the_mad_poster (640772) | more than 11 years ago | (#5141270)

I seriously hope no one paid them for this.

Are they telling me that if I write useless code intentionally I'm increasing my chance of errors as I increase my code?

Or, maybe they're saying that if I write useless code by mistake, I'm being careless which invites more errors?

Brilliant insight... I wish I had thought of all that before I turned my clear, concise 10 line application into a mangled mess of 100000 lines (hey look... I just rewrote the Windoze kernel!)

Well, duh! (1)

ucblockhead (63650) | more than 11 years ago | (#5141275)

Redundent code means the coder wasn't thinking. Hence more bugs.

Read it again for the first time.... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141282)

"Two Stanford researchers have written a paper showing that seemingly-harmless reposted Slashdot stories are frequently a sign of not so harmless editing errors. Examples of redundant stories: AP articles posted on both CNN and Salon, every incremental increase in a W3C standard, and seemingly every damn story about Legos. More on this story tomorrow when Hemos posts it."

IN SOVIET RUSSIA... (0, Funny)

Anonymous Coward | more than 11 years ago | (#5141283)

Errors find YOU! find YOU!

Re:IN SOVIET RUSSIA... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141497)

oh god, i actually found that funny.

someone shoot me, please.

Most prevalent source of redundant code.... (2, Funny)

1nv4d3r (642775) | more than 11 years ago | (#5141291)

Three letters: NIH.

Now, if you'll excuse me, I've got to get back to my text editor project.

Finding errors in your code (3, Funny)

Amsterdam Vallon (639622) | more than 11 years ago | (#5141293)

Isn't this the job of that smart dude down the hall who runs Lunix computers and reads some Slash Period website or something?

Well, at least that's how I finish all my projects.

Error checking compilers (1, Insightful)

Anonymous Coward | more than 11 years ago | (#5141297)

".. so run lint .."

I understand that there are non-C compilers out there that actually detect code errors without running a separate utility. Amazing!

Dead Code? (0)

Anonymous Coward | more than 11 years ago | (#5141310)

We have MS Windows conained inside of the kernel?

Re:Dead Code? (0)

yourmom16 (618766) | more than 11 years ago | (#5141373)

We have MS Windows conained inside of the kernel?

No its bsd thats dead, and you call yourself a troll?

For future woud be researchers (1, Informative)

Anonymous Coward | more than 11 years ago | (#5141313)

When posting pdf files, make sure you run your tex file through proper pdf creating tools (such as pdftex or pdflatex), rather than using half brain ps->pdf conversion tools that render fonts unreadble. Also test the legibility of your papers before posting them on a peer review site such as slashdot ;)

Intentional redundant code (5, Funny)

1nv4d3r (642775) | more than 11 years ago | (#5141329)

I've seen this (they were fired the next month):

// and now to boost my LOC/Day performance...
x += 0;
x += 0;
x += 0;
x += 0;
x += 0;
x += 0;

It actually caused a bug 'cuz they accidentally left the '+' off one of the lines. What an idiot.

Re:Intentional redundant code (4, Insightful)

gUmbi (95629) | more than 11 years ago | (#5141394)

I've seen this (they were fired the next month): // and now to boost my LOC/Day performance...


Was the manager asking for lines of code/day fired too?

Re:Intentional redundant code (2)

1nv4d3r (642775) | more than 11 years ago | (#5141490)

I think he just wanted to look like he was busy. We weren't judged by LOC/day, but we did take regular metrics. I guess he thought if the manager saw 400 new lines that week, the assumption would be that he was doing more work than he was.

Re:Intentional redundant code (0)

Anonymous Coward | more than 11 years ago | (#5141444)

"op=" is a bug created by Dennis Ritchie and remains uncorrected even today.

Re:Intentional redundant code (4, Insightful)

Anonymous Hack (637833) | more than 11 years ago | (#5141461)

Ugh, counting LOC sucks. I find my most productive days are the ones i REMOVE lines of code, not add them. If i get a loop running tighter and faster, if i remove stuff that i could do better another way... that's what i'm paid to do.

lint *is* available for Linux (0, Troll)

Amsterdam Vallon (639622) | more than 11 years ago | (#5141334)

While lint(1) "proper" doesn't exist for Linux (because copyright issues), you all could try lclint.

It's available at larch.lcs.mit.edu:/pub/Larch/lclint.

"If all you're doing is compiling programs that have lint(1) targets in the Makefile, you can probably just comment out (or remove) the lint targets and actions from the Makefile. If the program has already been ported to Linux, they won't produce anything of interest to you unless you are a developer. I hope this helps."

Jesus Saves! (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5141337)

Ask Jesus into your heart today!

Redundancy? (2, Funny)

kubrick (27291) | more than 11 years ago | (#5141341)

Ummm... surely if any story should be duped in the near future, it's this one. Please submit story suggestions accordingly.

Interesting Research (1)

Beatnick (560520) | more than 11 years ago | (#5141358)

Some code can be labeled as dead code but that
doesn't necessarily make the code non-useful
if the parameters and software requirements change.
I've placed code (don't flame me too hard) within
my own coded creations (with necessary documentation)
for future considerations that my clientele may
consider at a later date.

It's good to see an outside group looking over
various coding issues in Linux. It gives me
the feeling that most of the community provides
some scrutiny over its development which by
and large increases support of Linux.

Now that Microsoft has opened up its code (within limitations),
I would like to see (as I am sure some of you are)
someone check it over.

Just curious.

Saw his talk at FSE (5, Interesting)

owenomalley (103963) | more than 11 years ago | (#5141362)

I saw Dawson's talk at FSE (Foundations of Software Engineering). He uses static flow analysis to find problems in the code (like an advanced form of pclint). The most interesting part of his tool is in the ranking of the problem reports. He has developed a couple of heuristics that sort the problems by order of importance and they supposedly do a very good job. Static analysis tools find most of their problems in rarely run code, such as error handlers. Such problems are problematic and sometimes lead to non-deterministic problems, which are extremely hard to find with standard testing and debugging. (This is especially true, when the program under consideration is a kernel.) Dawson also verifies configurations of the kernel that no one would compile, because he tries to get as many possible drivers at the same time as he can. The more code, the better the consistency checks do at finding problems.

By making assumptions about the program and checking the consistency of the program, his tool finds lots of problems. For instance, assume there is a function named foo that takes a pointer argument. His tool will notice how many of the callers of foo treat the parameter as freed versus how many treat the parameter as unfreed. The bigger the ratio, the more likely the 'bad' callers are to represent a bug. It doesn't really matter which view is correct. If the programmer is treating the parameter inconsistently, it is very likely a bug.

He also mentioned that counter to his expectations, the most useful part of his tool was to find 'local' bugs. By local, I mean bugs that are local to a single procedure. They are both easier for the tool to find, more likely to actually be bugs, and much easier for the programmer to verify if they are in fact bugs.

He analyzed a couple of the 2.2.x and 2.4.x versions of the kernel and found hundreds of bugs. Some of them were fixed promptly. Others were fixed slowly. Some were fixed by removing the code (almost always a device driver) from the kernel. Others he couldn't find anyone that cared about the bug enough to fix it. He was surprised at the amount of abandonware in the Linux kernel.
It is extremely frustrating that Dawson won't release his tool to other researchers (or even better to the open source community at large). Without letting other people run his tool (or even better modify it), his research ultimately does little good other than finding bugs in linux device drivers. *heavy sigh* Oh well, eventually someone WILL reimplement this stuff and release it to the world.

On a snide comment, if he was a company he would no doubt have been bought by Microsoft already. Intrinsa was doing some interesting stuff with static analysis and now after they were bought a couple of years ago, their tool is only available inside of Microsoft. *sigh*

Re:Saw his talk at FSE (2, Interesting)

RodgerDodger (575834) | more than 11 years ago | (#5141502)

It is extremely frustrating that Dawson won't release his tool to other researchers (or even better to the open source community at large).

There's probably a bunch of reasons why he hasn't done this. The most likely one is that he's using it as a research tool, and he doesn't want someone else to beat him to the punch in his research. A second is that it's probably not really in a fit state for sharing as yet (the tool is not the goal of the research, after all).

He's got a bunch of papers up describing how the tool works, so it can be reimplemented. Also, if he's like most academics, he'll probably talk your ear off if you ask him how it works. :)

Concurrency Issues (0)

Anonymous Coward | more than 11 years ago | (#5141385)

As any good kernel volk know, concurrent programming can contain certain blocks of code that might seem redundant, even meaningless to the average procedural programmer. Hope they're not getting confused.

If unnecessary code is "redundant" (2, Interesting)

RhettLivingston (544140) | more than 11 years ago | (#5141393)

I suppose they've hit my pet peeve. I've seen many simple problems turned into hideous monstrosities with many bugs by people trying to handle bugs that can't ever happen and imaginary special cases because they were never taught how to abstract a function. Perhaps it can't be taught. In 20+ years of programming, its been a very rare time when I've picked up code and not been able to cut out large chunks without replacing them.

talk about redundant (0, Flamebait)

Cheeze (12756) | more than 11 years ago | (#5141423)

the article is in a pdf. now that redundancy.

are they just too lazy to "export to html" and put it up as a webpage?

and no, i don't want to load the adobe viewer. 30 megs of ram for a viewer program? there's probably 80% redundant code loaded into memory in that program alone

Re:talk about redundant (1)

mlk (18543) | more than 11 years ago | (#5141482)

Google is your friend [google.co.uk]

Dawson Engler's past life as a bodybuilder (0)

Anonymous Coward | more than 11 years ago | (#5141438)

http://www.pdos.lcs.mit.edu/~engler/jr-calif.html

That didn't make any sense at all! (1)

Daetrin (576516) | more than 11 years ago | (#5141439)

Until i realized that at 164% zoom all the equals signs looked like minus signs. I spend several minutes trying to figure out how that code could compile at all before i thought to turn the zoom up to 200% :)

Interestingly enough, 163% zoom doesn't cause the problem, nor does 165%. After a bit of experimenting i couldn't find any other isolated case that had the same results. There's a sudden transition to illegibility at 131%, but everything below that is also illegible. 164% is just odd, strange that that happened to be picked as the default when i opened it.

Double posting (1)

baywulf (214371) | more than 11 years ago | (#5141452)

Is that why there are so many double postings of articles on Slashdot? Trying to use redundancies to find errors?

"redundancies ... correlate with ... errors" (2, Interesting)

voodoo1man (594237) | more than 11 years ago | (#5141457)

At the risk of being modded redundant (hah!) I have to point out that a correlation between sloppy coding and errors does, in fact, exist. Many of us who write software have suspected this for a long time, and it is good to know that our hypothesis is supported by concrete research from the academic community, who seem to have finally proven that "redundancies seemed to flag confused or poor programmers who were prone to other error types."

Hopefully, we can expect much more of such valuable breakthroughs from the academic community in the future, complete with papers full of badly formatted C code!

Go Dawson! (0)

Anonymous Coward | more than 11 years ago | (#5141474)

Go Dawson Engler! I almost took an advanced OS course from him this quarter. But I must say, if you know where to look (his MIT website *hint* *hint*) you can find pictures of him all oiled up for a bodybuilding competition. The man is ripped.

Rates a 10 on the DUH scale... (1)

Dr. Bent (533421) | more than 11 years ago | (#5141477)

...but seriously tho, I've always found that it's best if you go out of your way to make sure that code is duplicated as little as possible. Sometimes it takes some major refactoring to move a method when you discover that it's needed someplace else, but it's almost always worth it in the time saved testing, debugging and keeping the methods in sync.

What does this mean (0)

Anonymous Coward | more than 11 years ago | (#5141496)

... about all those seemingly harmless redundant articles, then?
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>