• (cs)

    It's always good to start my week with a CodeSOD, it makes me feel so much better about my own code. Hopefully I know what I don't know.

  • kyiro (unregistered)

    Makes me think of the VB6 legacy app we have living around here somewhere. It's a big mess, would make a good entry on this site... But really, reading this makes me glad we stopped maintenance for that... thing...

  • (cs)

    Mmm, infinite recursion.

    I suppose I should be glad we don't get any of that here, even though it's only because someone was fond of monolithic methods that did everything.

  • blah (unregistered)

    The code was merely imitating its creator.

  • Cv (unregistered)

    Oh that's awesome! I'd love to see that baby go when disk's full or whatever other error (that will be repeated, which is basically any error) in that function occurs.

  • (cs)

    At least they didn't use 'On Error Resume Next'.

  • (cs)

    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

  • Mad Formatter (unregistered)

    But you don't understand. It is company policy that all errors are logged!

    Hey at least they got the date elements in the right order*:

    CStr(Year(Now)) & CStr(Month(Now)) & CStr(Day(Now))

    Oops, never mind:

    Format(Date, "mm/dd/yyyy")

    P.S. TDWTF is WTF'd again today...

  • (cs)

    I love the smell of infinite recursion in the morning. It smells like...failure.

  • (cs) in reply to campkev

    The site looks great today.. ads sometime missing for gray patches, the whole works.. mostly the banner section is haywire.

  • (cs)

    I like the "goto EndSub" instead of "exit sub".

    I want to blame the infinite loop on someone who was copying and pasting that code into everything without paying attention. Given their brillant commenting though, I somehow doubt this.

  • Christopher (unregistered)

    Don't forget, the logs for December 5th will be found in the January 25th file.

  • MC (unregistered)

    Oh, no! The error logger experienced an error! I'd better report this to the error logger.

  • (cs)

    I've only worked with VB6 on a handful of occasions, so I had no clue what was wrong with that code.

    Up until the point when it recursed on itself, that is.

  • Everett (unregistered)

    This is Brillant! If we can't write the log entry then try to write that error to the log!

  • blah (unregistered)

    These people need to get with the 21st century. They should do all logging on Twitter.

  • Anonymous (unregistered)

    Here is the painting of a landscape. But the artist who painted that picture says "something is missing; what is it? It is I myself who was a part of the landscape I painted". So he mentally takes a step backward, or 'regresses', and paints a picture of the artist painting a picture of the landscape. And still something is missing. That something is still his real self painting the second picture. So he 'regresses' further and paints a third, a picture of the artist painting a picture of the artist painting a picture of the landscape. And because something is still missing, he paints a fourth and fifth picture... so, infinite regression is the moment when our artist, having regressed to the point of infinity, himself becomes a part of the picture he has painted and is both the observer and the observed.

    Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

  • Sumit (unregistered)

    Sure is funny, to log an error when the error logger throws an error. My guess is that the ErrorHandler is a their general routine code they appended to all the functions without checking the function names.

    EDIT: Looks like Alex has incorporated this code into his aspx modules: I got this when I tried to submit my comment the first time:

    An Error Occured Not sure what it was, but it was logged. A human will eventually look at it. If the problem persists, please Contact Us. If the problem is on the contact form, then ... well ... that pretty much sucks.
  • aBase (unregistered)

    If only I could figure out what the uncommented lines do...

  • (cs)

    Only one problem: VB-everyversion really is that bad.

  • Alex (unregistered)

    I was reading through the code thinking "The comments are a bit odd, and they are being overdescriptive, but other than that it seems okay."

    Until I hit the Error Handler routine. As my eyes hit

        Call LogEntry("LogEntry: ", strError)
    

    I made this noise that sounded a bit like "nnnggn" and my left eyelid twitched.

    Awesome.

  • Barry Cunningham (unregistered)

    I swear I have worked on code just like this. Same log file naming error. Same kind of recursion error, although it may have been masked by another level of calls. Not nearly so many comments though, except maybe the odd 8 page block of commented out code.

  • (cs) in reply to Cv
    Cv:
    Oh that's awesome! I'd love to see that baby go when disk's full or whatever other error (that will be repeated, which is basically any error) in that function occurs.
    That reminds me of one time when I managed to inadvertently fill up the (pitifully small) /var filesystem on an old Solaris workstation, long ago. Things started out as being a little bit unhappy, but quickly got worse as syslog insisted on logging the fact that the filesystem was full and that it couldn't write to the log. For reasons I do not understand entirely, this rendered the whole machine unusable until it was hard rebooted (couldn't do a soft shutdown because that was logged...)

    All this was made worse by the fact that there was no indication at all as to what had caused the problem in the first place. (It was a combination of a strange front end to lpr that was struggling with printing a large document, and the aforementioned tiny filesystem, but it took quite a bit of work to find that out.)

  • (cs)

    No modern programmer needs to live with bad indentation.

    There are tools available, and have been available for more than a decade, that change the code to something readable, let you edit it, and then if necessary, change it back to the bad indentation pattern, your changes and all, for minimal source base diffs.

    Failure to recognize this just indicates a desire to punish oneself.

  • Honky (unregistered) in reply to Anonymous
    Anonymous:
    [snip] Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

    A better explanation is that you're a dumbass.

  • Herohtar (unregistered) in reply to java.lang.Chris;
    java.lang.Chris;:
    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

    I haven't worked with VB6 in a while so I don't remember how it handles things, but I'm not sure that would really be a race condition.

  • Javier (unregistered)

    Just change the color of the comments to a very light gray. You almost won't see them, but they'll be there in case you need clarification on some piece of code. And be thankful you have comments!.

  • (cs) in reply to Herohtar
    Herohtar:
    java.lang.Chris;:
    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

    I haven't worked with VB6 in a while so I don't remember how it handles things, but I'm not sure that would really be a race condition.

    It's not a vb thing; the race condition happens when more than one thread goes for the logger at the same time just after midnight (or right after starting up on a new day).

    Bonus points: what happens in the thread that doesn't create the log file?

  • (cs) in reply to kmarsh
    kmarsh:
    There are tools available that change the code to something readable Failure to recognize this just indicates a desire to punish oneself.

    ... Or just indicates that you're using the VB6 IDE to work on a VB6 programm ?

    Yes I know, VB6 in itself is punishment, but the intro clearly stated how unwillingly they walked that path.

  • Anonymous (unregistered) in reply to Honky
    Honky:
    Anonymous:
    [snip] Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

    A better explanation is that you're a dumbass.

    <WHOOOOOSH!!>

  • Patrick (unregistered)

    Yaaaaay! CodeSOD is back!

  • Patrick (unregistered) in reply to Alex
    Alex:
    I was reading through the code thinking "The comments are a bit odd, and they are being overdescriptive, but other than that it seems okay."

    Until I hit the Error Handler routine. As my eyes hit

        Call LogEntry("LogEntry: ", strError)
    

    I made this noise that sounded a bit like "nnnggn" and my left eyelid twitched.

    Awesome.

    It's like the gears in your brain suddenly jam up with a kerchunk squeak and you know you're in for a long day.

  • morry (unregistered)

    I found the comments on the left to be surprisingly readable.

  • bored (unregistered)

    Yeeeeah another RWTF, thanks for a cheerful Monday morning!

    Captcha; nulla - The table didn't allow nulla values.

  • ex-vb6-dev (unregistered) in reply to arty
    arty:
    Herohtar:
    java.lang.Chris;:
    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

    I haven't worked with VB6 in a while so I don't remember how it handles things, but I'm not sure that would really be a race condition.

    It's not a vb thing; the race condition happens when more than one thread goes for the logger at the same time just after midnight (or right after starting up on a new day).

    Bonus points: what happens in the thread that doesn't create the log file?

    Race conditions are not a vb6-thing... Only the greatest code wizards are able to use multiple threads in vb6.

  • Some Philosophy Guru (unregistered) in reply to Anonymous
    Anonymous:
    Here is the painting of a landscape. But the artist who painted that picture says "something is missing; what is it? It is I myself who was a part of the landscape I painted". So he mentally takes a step backward, or 'regresses', and paints a picture of the artist painting a picture of the landscape. And still something is missing. That something is still his real self painting the second picture. So he 'regresses' further and paints a third, a picture of the artist painting a picture of the artist painting a picture of the landscape. And because something is still missing, he paints a fourth and fifth picture... so, infinite regression is the moment when our artist, having regressed to the point of infinity, himself becomes a part of the picture he has painted and is both the observer and the observed.

    Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

    Not to rain on your existential thesis, but if all "lanes" from the past into the future exist simultaneously, then does "a driver, by changing lanes" actually change his future? Or just the future that he sees? (i.e.: Limits himself to perception of a single "lane", even though all the other "lanes" (alternate futures) exist.)

    Determinism: The reason you "choose" to believe you have free will.

  • ButHow (unregistered) in reply to kmarsh

    But how is the auto-indenter supposed to figure out if the comment is related to the line following it or the one preceding it? In this case the empty lines make it kinda obvious to a human, but I doubt this heuristic is built into most pretty printers.. That's why we like slashy //comments on the end of lines and a /* block comment */ preceding a method/subroutine.

  • silent d (unregistered) in reply to kmarsh
    kmarsh:
    No modern programmer needs to live with bad indentation.

    There are tools available, and have been available for more than a decade, that change the code to something readable, let you edit it, and then if necessary, change it back to the bad indentation pattern, your changes and all, for minimal source base diffs.

    Failure to recognize this just indicates a desire to punish oneself.

    Somehow I think cleaning up the comment indentation is not Matt's top priority here.

  • Paula (unregistered)

    Simple solution for the commentary: make their syntax highlit very close to background color. Easy to focus on actual code.

  • (cs) in reply to ex-vb6-dev
    ex-vb6-dev:
    arty:
    Herohtar:
    java.lang.Chris;:
    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

    I haven't worked with VB6 in a while so I don't remember how it handles things, but I'm not sure that would really be a race condition.

    It's not a vb thing; the race condition happens when more than one thread goes for the logger at the same time just after midnight (or right after starting up on a new day).

    Bonus points: what happens in the thread that doesn't create the log file?

    Race conditions are not a vb6-thing... Only the greatest code wizards are able to use multiple threads in vb6.

    What if there are multiple instances of the program on multiple desktops and the app is installed on a network drive?

  • Dr.Evil (unregistered) in reply to Anonymous
    Anonymous:
    Here is the painting of a landscape. But the artist who painted that picture says "something is missing; what is it? It is I myself who was a part of the landscape I painted". So he mentally takes a step backward, or 'regresses', and paints a picture of the artist painting a picture of the landscape. And still something is missing. That something is still his real self painting the second picture. So he 'regresses' further and paints a third, a picture of the artist painting a picture of the artist painting a picture of the landscape. And because something is still missing, he paints a fourth and fifth picture... so, infinite regression is the moment when our artist, having regressed to the point of infinity, himself becomes a part of the picture he has painted and is both the observer and the observed.

    Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

    Gary Busey?... Is that you?

  • OutlawProgrammer (unregistered)

    Reminds me of the time I decided to use our standard template for our error page, then somehow introduced a NullPointerException into the template. The resulting "Hall of Mirrors" effect reminded me of why I'm not allowed to create Quake 2 levels...

  • Patrick (unregistered) in reply to ButHow
    ButHow:
    But how is the auto-indenter supposed to figure out if the comment is related to the line following it or the one preceding it? In this case the empty lines make it kinda obvious to a human, but I doubt this heuristic is built into most pretty printers.. That's why we like slashy //comments on the end of lines and a /* block comment */ preceding a method/subroutine.
    That's easy, it's VB6 - it doesn't have an auto-indenter
  • Mike5 (unregistered) in reply to jmucchiello
    jmucchiello:
    ex-vb6-dev:
    arty:
    Herohtar:
    java.lang.Chris;:
    Mmm, race conditions. The schizophrenic class of bug, because it seems like your program has multiple personalities, all trying to write to the log at the same time.

    I haven't worked with VB6 in a while so I don't remember how it handles things, but I'm not sure that would really be a race condition.

    It's not a vb thing; the race condition happens when more than one thread goes for the logger at the same time just after midnight (or right after starting up on a new day).

    Bonus points: what happens in the thread that doesn't create the log file?

    Race conditions are not a vb6-thing... Only the greatest code wizards are able to use multiple threads in vb6.

    What if there are multiple instances of the program on multiple desktops and the app is installed on a network drive?

    What do you mean "What if...". With code like that you can bet your ass that is exactly the way it is.

    In other news, besides obvious infinite recursion, I really liked the comment about Dec. 5, Jan. 25 mixup. Nice catch!

  • (cs)

    Hey, at least it's well commented.

  • coyo (unregistered) in reply to amischiefr
    amischiefr:
    Hey, at least it's well commented.

    ' add 1 to x x = x + 1

    I'm sorry, a comment like that ads nothing. It's filler, like soy in a hot dog. It's bloated, fills you up and gives you gas.

    The only upside is it makes you look like you're putting in comments.

  • (cs) in reply to Anonymous
    Anonymous:
    Well, in that peculiar condition, what would he be observing if he were observing time?

    He would perceive that time is like a freeway with an infinite number of lanes all leading from the past into the future. But not into the same future. A driver in lane 'A' may crash, while a driver in lane 'B' survives. It follows that a driver, by changing lanes, can change his future.

    Do you believe that?

    Absolutely. I think it is the only explanation.

    Damn dirty apes.

  • Anonymous (unregistered)

    I wrote a VB6 program a long time ago that whenever an error occured it would show a message saying "[Error message] - full details of this error will be written to the log file".

    If writing the log then failed it then displayed the message "Regrettably an error occured writing to the error log - this is just going to be one of those days.".

    It was over 6 years before a client reported getting that message :P

  • acsii (unregistered) in reply to operagost
    he them
    Who cares about he them? What about she them?
  • (cs)

    I've seen my quote of loggers that log logger's errors, but this one composes that with oppening the error file every time it is called, race conditions at that oppening, that make logging errors a sure condition, and bad comments! That is precious!

    On a side note, that can't be code of a web application. It must be on single threaded desktop software. It wouldn't live for half an hour at a massively paralel web server.

Leave a comment on “Desperate Times”

Log In or post as a guest

Replying to comment #:

« Return to Article