- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I can't imagine what he's complaining about . . . after all, there is a helpful, accurate comment right on the line he's looking at. Score!
Admin
Ok, not the best way of saying what an invalid session is, but at least the code was commented and it was clear what it did.
Admin
Hmm by that logic: I was born in the early 1980's....that was last millennium....which means I've been living over 1000 years! Result!
Admin
//A weekend has passed. This must be another Daily WTF Post->write("new comment");
Admin
I have a choice of:
This is a comment I wrote yesterday, it must definitely be invalid.
Or:
Eventually, bad things will happen in the following pieces of code:
//this is definitely [anything]
if(exp1) { //DO } else if(exp2) { //Do Something Else } else { //This condition will never be true //Do nothing }
Also seen while at was at university, one of my tutors provided the following "Infinite Loop":
System.out.println("I am going to loop."); for(int counter = 0; counter => 0; counter ++) { //This will happen forever } System.out.println("You have now entered the twilight zone."); // This will never happen
I had to point that one out.
Admin
Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix.
It could do, I guess. But a repeatable bug, caused by code accurately commented with text which should be amongst the first thing you'd grep for shouldn't take more than a few mins to fix. This wouldn't make a bad interview task for a company which wishes to weed out jumped up HTML hairdressers who think they can code because they know a bit of javascript from actual programmers.
Admin
How about "The Daily Oh... Fixed"?
Admin
I got stumped on this one some time ago:
for (byte b = 0; b <= 255; b++) { // stuff }
Admin
Admin
But that will put everyone in the twilight zone! (2147483647 + 1 = -2147483648.)
Admin
I just did a grep for the counterpart to "Disconnect" in the system I work on - 6 occurrences out of 400K + LOC - elapsed time: 30 seconds + 3 minutes to read each in context.
What, exactly, took Rajesh 1/2 day to figure out?
Admin
Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.
Admin
Well it was his first task on the job. Some codebases I've worked on, it takes half a day just to figure out where to grep.
Admin
Admin
Was the intention to show what happens when ints overflow, or was he just being dumb?
while(TRUE){ // loop forever }
Admin
If this is the Raj from my company, I'd add this question to this reseaarch on this code: "If you're a global company with offices in the US, Europe, India and Southeast Asia, just when is midnight?
Admin
True, but there are pretty good signs this is Java, where int is guaranteed to be 32 bits.
If we don't assume programming language, "int" could be unsigned by default, which would make the loop properly infinite (without contradicting your statement, of course).
Jon
Admin
Unfortunately, that was one of about 10 examples (Including the one you just gave) that were supposed to be infinite loops. I did have to explain why it wasn't, although he did seem to understand the overflow thing, meaning that it was just an oversight, however, he did try and bluff his way out of it with "Well, it will last a very long time, it might as well be an infinite loop".
Admin
It was Java. C++ tutor.
Admin
for (byte b = 0; b <= 127; b++) { }
Is infinite. Bytes in Java are always signed. In fact, the only unsigned data type in Java is char, just to prove that Java abhors consistency.
Admin
actually, you only need b<=127 if that's a signed byte(which is the default in all of the languages I've dealt with so far)
Admin
Admin
Admin
I think the time to fix was for the fallout of the dropped connections, not for fixing the disconnect issue.
Admin
Admin
Fixing a bug on the basis of one line of code/one comment can turn into a much larger WTF than the original issue ever was; especially in an application as reportedly complex as this one.
Admin
If that comment wasn't there, he would be left wondering if this code did something important or was a blatant misunderstanding of time and space. With the comment it is clear.
Admin
Whenever I see a simple comment/piece of code like that in a monster system it makes me feel like it's a trapped door. Once you remove it other more monstrous issues are set free.
Admin
boolean paul = true, brilliant = true;
while(paula == brilliant) {
}
Admin
[iwan@10-70-8-41 ~]$ time java Test I am going to loop. You have now entered the twilight zone.
real 0m1.057s user 0m0.990s sys 0m0.023s
Yup, that's truely a very long time...
Admin
I know that if I saw a door trapped, I would set it free. "Run little door! The trappers are going to make a coat out of you!"
Admin
My Mad Skillz is very rusty, but what does "=>" do? If it's a new-fangled assignment, it's going to loop forever. Otherwise, it will just give a compile warning and fail.
At least, I would hope.
Admin
Admin
If I was assigned to diagnose a problem like that, I don't think I'd start out with the assumption that there was a deliberate disconnect of all active sessions every day at midnight, and so just search for a disconnect call. I don't think it would even occur to me that a programmer would be stupid enough to write code like that. I'd start out looking for something complicated. So taking a half a day to find the stupid code doesn't sound bad to me at all.
It's difficult to make any system foolproof, because fool's are so creative.
Admin
Besides, the latest chip from Intel is so fast that it can execute an infinite loop in 12 seconds.
Admin
guess this will never execute.. paul is true, paula is undefined (probably false)
Admin
=> is used in C# for lambda expressions. You can write sum(someList, i => i<=5); Which would add all numbers in someList which is less or equal to five.
It's no good in Java so I think its a typo.
Admin
Admin
You misspelled "Brillant".
Admin
I think that Jon's post was part of the discussion about 'infinite loops', rather than the original post. Come on, keep up!
Admin
He didn't know what to grep for
Admin
Admin
Admin
Admin
np: Justus Köhncke - Molybdän (Safe And Sound)
Admin
Admin
Yes that was a whoosh. There's a person on the forums who write this VBScript (or something) program that performs searches, however you have to create a single file with everything concatenated into it.
For searching I would do something like
find . -exec grep -iH disconnect {} ;
YMMV
Admin
The real WTF: an advertisement for scientology turned up on this page. So they are sick of actors now and going after programmers? Xenu help us.
Admin
It doesn't do anything in the loop, so it doesn't do anything at all. The proper way to halt in place (assuming that there even is one) is to call select() on an empty FD set. On java, you can just do wait().
Admin