• (cs)

    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!

  • S (unregistered)

    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.

  • m (unregistered)

    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!

  • (cs)

    //A weekend has passed. This must be another Daily WTF Post->write("new comment");

  • (cs)

    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.

  • Dave (unregistered) in reply to S
    S:
    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.

    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.

  • (cs) in reply to Dave
    Dave:
    Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix.

    How about "The Daily Oh... Fixed"?

  • SlyEcho (unregistered) in reply to NaN
    NaN:
    I have a choice of:

    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.

    I got stumped on this one some time ago:

    for (byte b = 0; b <= 255; b++) { // stuff }

  • (cs) in reply to NaN
    NaN:
    Dave:
    Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix.

    How about "The Daily Oh... Fixed"?

    The Daily Oh-My! What-The-Fudge!?

  • sdfdfsdfsqdf (unregistered) in reply to NaN
    NaN:
    I have a choice of:

    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

    But that will put everyone in the twilight zone! (2147483647 + 1 = -2147483648.)

  • (cs) in reply to snoofle

    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?

  • (cs) in reply to sdfdfsdfsqdf
    sdfdfsdfsqdf:
    NaN:
    I have a choice of:

    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

    But that will put everyone in the twilight zone! (2147483647 + 1 = -2147483648.)

    Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.

  • (cs) in reply to snoofle
    snoofle:
    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?

    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.

  • (cs) in reply to vt_mruhlin
    vt_mruhlin:
    snoofle:
    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?

    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...

  • Matt (unregistered) in reply to NaN
    NaN:
    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.

    Was the intention to show what happens when ints overflow, or was he just being dumb?

    while(TRUE){ // loop forever }

  • greyrat (unregistered)

    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?

  • Jon Skeet (unregistered) in reply to mallard
    mallard:
    Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.

    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

  • NaN (unregistered) in reply to Matt
    Matt:
    NaN:
    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.

    Was the intention to show what happens when ints overflow, or was he just being dumb?

    while(TRUE){ // loop forever }

    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".

  • NaN (unregistered) in reply to Jon Skeet
    Jon Skeet:
    mallard:
    Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.

    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

    It was Java. C++ tutor.

  • Anon (unregistered) in reply to SlyEcho
    SlyEcho:
    I got stumped on this one some time ago:

    for (byte b = 0; b <= 255; b++) { // stuff }

    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.

  • entropy (unregistered) in reply to SlyEcho
    SlyEcho:

    I got stumped on this one some time ago:

    for (byte b = 0; b <= 255; b++) { // stuff }

    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)

  • (cs) in reply to NaN
    NaN:
    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".
    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)
    {
        // Loop indefinitely.
    }
    There's also the following that I've seen suggested as a joke (wouldn't recommend it myself)...
    #define EVER ;;
    for(EVER)
    {
        // Loop indefinitely.
    }
  • (cs) in reply to xtremezone
    xtremezone:
    I keep my infinite loops simple though. :)
    I like this one:
    while (2) {...}
  • (cs) in reply to snoofle
    snoofle:
    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?

    I think the time to fix was for the fallout of the dropped connections, not for fixing the disconnect issue.

  • Gertjan (unregistered) in reply to dpm
    dpm:
    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!
    Obviously the whole WTF is that the line does not check for a day 'passed', but a day 'wrapped'. So the comment is incorrect.
  • GF (unregistered) in reply to snoofle
    snoofle:
    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?

    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.

  • mccoyn (unregistered)

    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.

  • for(EVER) (unregistered)

    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.

  • (cs) in reply to xtremezone

    boolean paul = true, brilliant = true;

    while(paula == brilliant) {

    }

  • Iwan (unregistered) in reply to NaN
    NaN:
    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".

    [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...

  • (cs) in reply to for(EVER)
    for(EVER):
    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.

    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!"

  • (cs) in reply to NaN
    NaN:
    snip 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.

    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.

  • (cs) in reply to snoofle
    snoofle:
    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?

    So the REAL WTF is that he only works 9-11
  • Jay (unregistered) in reply to snoofle
    snoofle:
    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?

    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.

  • Jay (unregistered) in reply to NaN
    NaN:
    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".

    Besides, the latest chip from Intel is so fast that it can execute an infinite loop in 12 seconds.

  • (cs) in reply to NaN
    NaN:
    boolean paul = true, brilliant = true;

    while(paula == brilliant) {

    }

    guess this will never execute.. paul is true, paula is undefined (probably false)

  • (cs) in reply to jimlangrunner
    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.

    => 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.

  • Pretty Good Sign (unregistered) in reply to Jon Skeet
    Jon Skeet:
    mallard:
    Not all systems have 32-bit integers.
    True, but there are pretty good signs this is Java, where int is guaranteed to be 32 bits.
    Such as the "written in C++" bit on the second line of the original post?
  • (cs) in reply to NaN
    NaN:
    boolean paul = true, brilliant = true;

    while(paula == brilliant) {

    }

    You misspelled "Brillant".

  • Bobbo (unregistered) in reply to Pretty Good Sign
    Pretty Good Sign:
    Jon Skeet:
    mallard:
    Not all systems have 32-bit integers.
    True, but there are pretty good signs this is Java, where int is guaranteed to be 32 bits.
    Such as the "written in C++" bit on the second line of the original post?

    I think that Jon's post was part of the discussion about 'infinite loops', rather than the original post. Come on, keep up!

  • ClaudeSuck.de (unregistered) in reply to snoofle
    snoofle:
    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?

    He didn't know what to grep for

  • (cs) in reply to ClaudeSuck.de
    snoofle:
    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?

    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.
  • (cs) in reply to GettinSadda
    GettinSadda:
    snoofle:
    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?

    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!
  • (cs) in reply to greyrat
    greyrat:
    If you're a global company with offices in the US, Europe, India and Southeast Asia, just when _is_ midnight?
    Mu.
  • (cs) in reply to xtremezone
    xtremezone:
    There's also the following that I've seen suggested as a joke (wouldn't recommend it myself)...
    #define EVER ;;
    for(EVER)
    {
        // Loop indefinitely.
    }
    There's nothing wrong with
    for(;;)
    {
      // #+*@%&!
    }
    
    though...

    np: Justus Köhncke - Molybdän (Safe And Sound)

  • scottl (unregistered) in reply to KNY
    KNY:
    GettinSadda:
    snoofle:
    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?

    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!
    Ummm... you can run grep recursively on a top level directory... Or is that sound I hear a joke going over my head?
  • (cs)

    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

  • shocked (unregistered)

    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.

  • Franz Kafka (unregistered) in reply to NaN
    NaN:
    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".

    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().

  • matt (unregistered) in reply to snoofle
    snoofle:
    NaN:
    Dave:
    Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix.

    How about "The Daily Oh... Fixed"?

    The Daily Oh-My! What-The-Fudge!?

    The Daily.... oh... that's easy enough. Well, That's Fixed.

Leave a comment on “The Nightly Session Drop”

Log In or post as a guest

Replying to comment #:

« Return to Article