|
|
|
| Non-WTF Job: Software Developer at Rustici Software (Franklin, Tennessee) |
| « Prev | Page 1 | Page 2 | Next » |
|
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!
|
|
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.
|
|
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!
|
|
//A weekend has passed. This must be another Daily WTF
Post->write("new comment"); |
|
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. |
Re: The Nightly Session Drop
2008-04-28 08:27
•
by
Dave
(unregistered)
|
Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix. > This would occasionally lead to ‘really bad things’ that > could take all day 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. |
How about "The Daily Oh... Fixed"? |
Re: The Nightly Session Drop
2008-04-28 08:48
•
by
SlyEcho
(unregistered)
|
I got stumped on this one some time ago: for (byte b = 0; b <= 255; b++) { // stuff } |
The Daily Oh-My! What-The-Fudge!? |
Re: The Nightly Session Drop
2008-04-28 08:51
•
by
sdfdfsdfsqdf
(unregistered)
|
But that will put everyone in the twilight zone! (2147483647 + 1 = -2147483648.) |
|
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? |
Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers. |
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. |
Fair enough... |
Re: The Nightly Session Drop
2008-04-28 09:24
•
by
Matt
(unregistered)
|
Was the intention to show what happens when ints overflow, or was he just being dumb? while(TRUE){ // loop forever } |
|
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?
|
Re: The Nightly Session Drop
2008-04-28 09:45
•
by
Jon Skeet
(unregistered)
|
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 |
Re: The Nightly Session Drop
2008-04-28 09:50
•
by
NaN
(unregistered)
|
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". |
Re: The Nightly Session Drop
2008-04-28 09:51
•
by
NaN
(unregistered)
|
It was Java. C++ tutor. |
Re: The Nightly Session Drop
2008-04-28 10:03
•
by
Anon
(unregistered)
|
Assuming Java, something as simple as: 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. |
Re: The Nightly Session Drop
2008-04-28 10:12
•
by
entropy
(unregistered)
|
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) |
The overflow didn't occur to me when I was looking at the code. My excuse is that I'm tired... I keep my infinite loops simple though. :) while(true) There's also the following that I've seen suggested as a joke (wouldn't recommend it myself)... #define EVER ;; |
I like this one: while (2) {...}
|
Re: The Nightly Session Drop
2008-04-28 10:41
•
by
Mirvnillith
|
I think the time to fix was for the fallout of the dropped connections, not for fixing the disconnect issue. |
Re: The Nightly Session Drop
2008-04-28 10:51
•
by
Gertjan
(unregistered)
|
Obviously the whole WTF is that the line does not check for a day 'passed', but a day 'wrapped'. So the comment is incorrect. |
Re: The Nightly Session Drop
2008-04-28 10:53
•
by
GF
(unregistered)
|
Well, if he's any good, he would have cross-referenced that method/function to determine under which conditions it's being called, and from where. After doing that, he would have had to ensure that he tested (or ran unit tests) for all scenarios; including setting up the same border condition that caused the issue in the first place. Too, he should also be testing with a session that actually /is/ 23 hours old (or simulated as such) to make sure that there are no issues encountered. 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. |
|
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.
|
|
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.
|
|
boolean paul = true, brilliant = true;
while(paula == brilliant) { } |
Re: The Nightly Session Drop
2008-04-28 11:12
•
by
Iwan
(unregistered)
|
[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... |
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!" |
Re: The Nightly Session Drop
2008-04-28 11:17
•
by
jimlangrunner
|
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. |
So the REAL WTF is that he only works 9-11 |
Re: The Nightly Session Drop
2008-04-28 11:27
•
by
Jay
(unregistered)
|
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. |
Re: The Nightly Session Drop
2008-04-28 11:30
•
by
Jay
(unregistered)
|
Besides, the latest chip from Intel is so fast that it can execute an infinite loop in 12 seconds. |
Re: The Nightly Session Drop
2008-04-28 11:37
•
by
pitchingchris
|
guess this will never execute.. paul is true, paula is undefined (probably false) |
=> 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. |
Re: The Nightly Session Drop
2008-04-28 11:58
•
by
Pretty Good Sign
(unregistered)
|
Such as the "written in C++" bit on the second line of the original post? |
You misspelled "Brillant". |
Re: The Nightly Session Drop
2008-04-28 12:20
•
by
Bobbo
(unregistered)
|
I think that Jon's post was part of the discussion about 'infinite loops', rather than the original post. Come on, keep up! |
Re: The Nightly Session Drop
2008-04-28 12:22
•
by
ClaudeSuck.de
(unregistered)
|
He didn't know what to grep for |
Re: The Nightly Session Drop
2008-04-28 12:38
•
by
GettinSadda
|
It only took 0.004 seconds to locate the bug, but that was after spending half a day merging all the source into a single file so his brillant search tool would work. |
I hereby nominate this to be a featured comment. Brillant! |
Mu. |
There's nothing wrong with for(;;)though... np: Justus Köhncke - Molybdän (Safe And Sound) |
Re: The Nightly Session Drop
2008-04-28 13:44
•
by
scottl
(unregistered)
|
Ummm... you can run grep recursively on a top level directory... Or is that sound I hear a joke going over my head? |
|
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 |
|
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.
|
Re: The Nightly Session Drop
2008-04-28 16:05
•
by
Franz Kafka
(unregistered)
|
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(). |
Re: The Nightly Session Drop
2008-04-28 16:37
•
by
matt
(unregistered)
|
The Daily.... oh... that's easy enough. Well, That's Fixed. |
| « Prev | Page 1 | Page 2 | Next » |