• gnasher729 (unregistered) in reply to Iggy
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

  • TSF (unregistered)
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

  • anonymous (unregistered) in reply to gnasher729
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    
  • (cs)

    TRWTF is Bruce's abysmal spelling.

  • (cs) in reply to oheso
    oheso:
    faoileag:
    You were lucky! Where I once worked, we had to make do with paper clips!

    LUUUUUUUUUXURY!!!!

    Years before Bear Stearns imploded, I worked there, and the first thing they did was give you an envelope with 50 paper clips in it, and a note explaining that these would be the last you'd ever see becasue paper clips were a needless expense...

  • (cs) in reply to anonymous
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    
    Diabolical! But I'd hesitate to work with anyone who even thought to write up something like that
  • (cs) in reply to Steve The Cynic
    Steve The Cynic:
    int main(void) {
    while(1) fork();
    return 0;
    }
    This is the simplest example.

    I do not think it does what you think it does.

    In the parent process, fork(2) returns -1 on failure and the child process's pid on success. In the child process, it returns 0. Thus, what this program does is create a series of child processes, each of which immediately exit. However, if it manages to fill the process table or hit the process limit (RLIMIT_NPROC), it will simply spin until it can fork again, because fork(2) will return -1, which evaluates to true.

    The simplest example is this:

    #include <unistd.h>
    int main(void) { while (1) fork(); }
    

    which will reproduce exponentially, because each child process will also fork an infinite series of child processes, each of which will fork an infinite series of child processes, and so on ad nauseam.

    So perhaps TRWTF is not Bruce's abysmal spelling, as I wrote earlier, but the number of readers who think they know C.

    Addendum (2014-04-14 13:08): ETA: I read your code as "while (fork());" instead of "while (1) fork();". Forget I ever said anything.

  • (cs) in reply to anonymous
    anonymous:
    Better:
    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    

    You might as well have written

    fork()
    

    because your program will just fork once and then exit, then the child process will fork once and then exit, etc. At some point, PIDs will roll around and a process might get lucky and start a few more dynasties. The chance of this happening is greatly reduced if PID randomization is enabled, and zero on FreeBSD where PIDs below 100 are reserved for kernel processes (except for 1, which is reserved for init(8)). This may also be the case on Linux - I can't be bothered to check.

    (hint: on success, fork(2) returns the PID of the child process)

  • Shan (unregistered) in reply to snoofle
    snoofle:
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    
    Diabolical! But I'd hesitate to work with anyone who even thought to write up something like that

    Actually, i += fork() kills the fork bomb. Most likely, the child PID is going to be > 100 so each thread creates one child thread and goes out of the loop. You end up with just a 100 deep stack; that too with each thread doing nothing except one child thread spawn and quit.

  • (cs) in reply to Shan
    Shan:
    Actually, i += fork() kills the fork bomb. Most likely, the child PID is going to be > 100 so each thread creates one child thread and goes out of the loop. You end up with just a 100 deep stack; that too with each thread doing nothing except one child thread spawn and quit.

    Ah, I failed to take the increment into account; i is effectively a bounded generation counter.

  • Shan (unregistered) in reply to DES
    DES:
    Steve The Cynic:
    int main(void) {
    while(1) fork();
    return 0;
    }
    This is the simplest example.

    I do not think it does what you think it does.

    In the parent process, fork(2) returns -1 on failure and the child process's pid on success. In the child process, it returns 0. Thus, what this program does is create a series of child processes, each of which immediately exit. However, if it manages to fill the process table or hit the process limit (RLIMIT_NPROC), it will simply spin until it can fork again, because fork(2) will return -1, which evaluates to true.

    The simplest example is this:

    #include <unistd.h>
    int main(void) { while (1) fork(); }
    

    which will reproduce exponentially, because each child process will also fork an infinite series of child processes, each of which will fork an infinite series of child processes, and so on ad nauseam.

    So perhaps TRWTF is not Bruce's abysmal spelling, as I wrote earlier, but the number of readers who think they know C.

    Steve's example and yours are the same. As per C99 & C++98, "If control reaches the end of main without encountering a return statement, the effect is that of executing return 0".

    When the child process is forked, it is still within that while infinite loop and is never going to exit the while loop to hit the return statement, implicit or explicit.

  • (cs) in reply to Shan
    Shan:
    Steve's example and yours are the same.

    Indeed they are. I somehow read it as "while (fork());" instead of "while (1) fork();". My bad.

  • Ol' Bob (unregistered)

    The real WTF is why Ray bought beers for the sysadmins. I mean, it's not like they did anything...

    (CAPTCHA: praesent - I guess it was Ray's way of buying them a little praesent...)

  • Ol' Bob (unregistered) in reply to faoileag
    faoileag:
    Shinobu:
    Am I the only one who thinks it reading a tedious political tractate, just to find out it was about a lousy fork bomb, wasn't worth it?
    No, you are not.

    Yes, you are.

    (CAPTCHA: appellatio - I am so lucky - I met this girl at the bar who's really into appellatio...)

  • Ol' Bob (unregistered) in reply to Programmer Dude
    Programmer Dude:
    Heck, the Sys Admins should be the ones buying the beer! They neither found nor fixed the problem. They just waited on the DEV to show up, went and got him and then scratched their poopers and let him figure it out.

    Yeah, this round should be on the Sys Admins.

    And is this somehow unusual?

  • Ol' Bob (unregistered) in reply to faoileag
    faoileag:
    "(ray) followed the proscribed steps"

    Leaving the typo aside, this tells us that a detailed guide existed to test any scripts that are meant to be run on the production server. This is obiously good, as it minimizes the risk of something strange happening.

    Why then, are not all scripts tested on the test server?

    Had rous_at_job.sh been tested on the test server, the infinite recursion would have been detected on the test server instead of on the production server after a night of standstill.

    While your point is well taken, let's apply a reality filter here. Let's consider what would happen when the bomb script was run on the test server and it locked up tighter'n...something that's really, really tight:

    "Hey, the test server's down!" "Define 'down'." "Uhhh...I can't log in to a command window..." "Can you ping it?" "Uhhh...yup, sure can". "Reboot it". "Yeah, but that's the third time this morning". "Yeah, well, it's been doing that lately. Dunno what's wrong with it. We always get the crappy machines for test. I think that's a 386 running NT 3.1. If they'd just give us decent test machines...(blah-blah-blah)"

    ...and thus the bomb script would have eventually been cleared for release, without actually being run successfully. I mean, c'mon, what could go wrong..?

    (CAPTCHA: abbas - that guy is so ripped he's got an abbas...)

  • Ol' Bob (unregistered) in reply to Black Bart
    Black Bart:
    Calf leather bound volumes of printouts? In industry, we always used blue plastic leather bound volumes of printouts.

    This is government. Your tax dollars at play...

  • Ol' Bob (unregistered) in reply to dkf
    dkf:
    operagost:
    "Fezzik's down!", he said.
    "Inconceivable!"
    That word. I do not think it means what you think it means.

    "Who are you?" "No one to be trifled with". "I must know". "Get used to disappointment".

  • Ol' Bob (unregistered) in reply to TSF
    TSF:
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

    Sure - but not out of the comments. :-)

    (CAPTCHA: uxor - I went me to Eee-gypped and saw me them ol' Temples at Uxor..!)

  • Ol' Bob (unregistered) in reply to snoofle
    snoofle:
    oheso:
    faoileag:
    You were lucky! Where I once worked, we had to make do with paper clips!

    LUUUUUUUUUXURY!!!!

    Years before Bear Stearns imploded, I worked there, and the first thing they did was give you an envelope with 50 paper clips in it, and a note explaining that these would be the last you'd ever see becasue paper clips were a needless expense...
    So, kind of, mind the little things and the big things will take care of themselves? Yeah, that worked well...

  • anonymous (unregistered) in reply to Shan
    Shan:
    snoofle:
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    
    Diabolical! But I'd hesitate to work with anyone who even thought to write up something like that

    Actually, i += fork() kills the fork bomb. Most likely, the child PID is going to be > 100 so each thread creates one child thread and goes out of the loop. You end up with just a 100 deep stack; that too with each thread doing nothing except one child thread spawn and quit.

    Exactly, since the point was to spawn 100 child threads. It does it... usually.

  • gnasher729 (unregistered) in reply to anonymous
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    

    No, that's just a boring old fork bomb. The original code, that's interesting for an interview.

  • gnasher729 (unregistered) in reply to gnasher729
    gnasher729:
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    

    No, that's just a boring old fork bomb. The original code, that's interesting for an interview.

    Bugger, you're right :-(

  • (cs) in reply to my name
    my name:
    oheso:
    The Balance:
    Proscribe != Prescribe. They almost mean opposite things;

    "Following the proscribed steps" should have immediately seen Ray disciplined.

    QFT. Is it so difficult to find editors with some familiarity with the English language?

    Based on how many other typos there were (I counted three, but might've missed some), I think we already know the answer to this....

    The editors often submit articles from a smartphone without any sorting of spell checking, which is TRWTF.

  • (cs) in reply to oheso
    oheso:
    operagost:
    "Fezzik's down!", he said.

    "Inconceivable!"

    Nah, that was an everyday occurrence with Fezzik. He's the Monica Lewinsky of servers named for fictional giants.

    It only takes 127 beers for Fezzik to go down.

  • (cs) in reply to snoofle
    snoofle:
    oheso:
    faoileag:
    You were lucky! Where I once worked, we had to make do with paper clips!

    LUUUUUUUUUXURY!!!!

    Years before Bear Stearns imploded, I worked there, and the first thing they did was give you an envelope with 50 paper clips in it, and a note explaining that these would be the last you'd ever see becasue paper clips were a needless expense...

    That envelope of paper clips was too big to fail!

  • (cs) in reply to TSF
    TSF:
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

    This article is obviously commentary on how Bush invaded Kenya for oil and to find Obama's real birth certificate.

  • The Itilian Stillion (unregistered)

    Because I can. The last line of this WTF uses the phrase 'going forward'. Can I ask what this means? If, as I am loathe to suggest, it is supposed to mean 'from this point on', or simply 'from now' or the sci-fi freakout of 'in the future' (god forbid) this begs the question.

    What might the logical alternative to 'going forward' actually be? If it`s what I think it is please confirm what Mr Einsteins reaction was when it was explained to him.

  • swschrad (unregistered)

    been there, done that, on the acedemic services VAX. quick fix, blow the logfile from the console. not quite a hero, not quite a zero. but I ended up splitting the joined drive I was carving students out of in the end, and that was heroic for uptime.

  • pouzzler (unregistered)

    You don't post pieces on a highly read site if you can't write perfect english, "writer".

  • J (unregistered) in reply to The Balance
    The Balance:
    Proscribe != Prescribe. They almost mean opposite things;

    "Following the proscribed steps" should have immediately seen Ray disciplined.

    Just like "compose" versus "comprise" - another common error.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to anonymous
    anonymous:
    ¯\(°_o)/¯ I DUNNO LOL:
    Mmm, yes, it needs to be changed to ++i to work properly.
    More likely Iggy meant for (i = 0; i < 100; ++ i) and just misremembered the syntax. Still a good catch, I suppose. I didn't notice it.
    You have missed the subtlety of my answer. Considering it's just a fork bomb, it doesn't actually have to stop at 100 (it would have never made it anyhow), it just needs to keep forking.

    If I ever have to write underhanded C code, I'll try to remember swapping the comparison and the increment in a for statement, because I sure didn't notice it until nitPicker pointed it out. Playing fast and loose with i++ vs ++i adds to the underhandedness.

  • (cs) in reply to QJo
    QJo:
    Voilà le vrai ce qui le baise.
    plus un
  • (cs) in reply to Zylon
    Zylon:
    If I didn't know better I'd assume someone sat down to deliberately write a parody of everything that these articles get mocked for.

    Needs more Helmut, or Heinrick, or whateverthefuck his name is.

  • Fernando (unregistered)
    This was before deficit hawks made a sport of picking off small cost overruns.
    Google "Proxmire Golden Fleece Award".
  • (cs) in reply to TSF
    TSF:
    Can we please keep the politics out of these articles?
    It wasn't the politics per se that constituted TRWTF of this article's writing. It's entirely possible to include politics in an article in a way that's entertaining, or adds to the story, or both.

    Neither was the case here.

  • (cs) in reply to snoofle
    snoofle:
    Bear Stearns imploded

    I got about 50 monitors donated out of that. Good show!

  • (cs) in reply to DES
    DES:
    Forget I ever said anything.

    Done!

  • Shan (unregistered) in reply to anonymous
    anonymous:
    Shan:
    snoofle:
    anonymous:
    gnasher729:
    Iggy:
    for (i=0; i++; i <100)
    {
     fork();
    }
    

    so instead of nice 100 child processes there were quite a few more...

    That would make an excellent interview question if you want to be nasty...

    Better:

    for (i = 0; i < 100; ++ i) {
      i += fork();
    }
    
    Diabolical! But I'd hesitate to work with anyone who even thought to write up something like that

    Actually, i += fork() kills the fork bomb. Most likely, the child PID is going to be > 100 so each thread creates one child thread and goes out of the loop. You end up with just a 100 deep stack; that too with each thread doing nothing except one child thread spawn and quit.

    Exactly, since the point was to spawn 100 child threads. It does it... usually.

    The point was to spawn 2**100 threads and kill the system. 100 threads don't even cut it close.

  • Reductio Ad Ridiculousum (unregistered) in reply to faoileag
    faoileag:
    "(ray) followed the proscribed steps"

    Leaving the typo aside, this tells us that a detailed guide existed to test any scripts that are meant to be run on the production server. This is obiously good, as it minimizes the risk of something strange happening.

    Why then, are not all scripts tested on the test server?

    Had rous_at_job.sh been tested on the test server, the infinite recursion would have been detected on the test server instead of on the production server after a night of standstill.

    Note: Dev servers are special cases. It's best to have another server, call it QA. This runs the install to a pristine box, emulating what would happen in production. Note note: there's no budget for a QA server.

  • (cs) in reply to TSF
    TSF:
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

    Why? Is the truth too challenging for you?

  • (cs) in reply to Ol' Bob
    Ol' Bob:
    snoofle:
    oheso:
    faoileag:
    You were lucky! Where I once worked, we had to make do with paper clips!

    LUUUUUUUUUXURY!!!!

    Years before Bear Stearns imploded, I worked there, and the first thing they did was give you an envelope with 50 paper clips in it, and a note explaining that these would be the last you'd ever see becasue paper clips were a needless expense...
    So, kind of, mind the little things and the big things will take care of themselves? Yeah, that worked well...

    You'd probably still have those paperclips because what you'd do is receive as many memos paperclipped together as you sent.

  • Reductio Ad Ridiculousum (unregistered) in reply to Matt Westwood
    Matt Westwood:
    TSF:
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

    Why? Is the truth too challenging for you?

    You and I and we and they may or may not agree with the politics. There's enough sites out there that are polluted with politics. Let's keep this site focused on its main purpose: lambasting the failures of submitters and editors to execute correct grammar, vocabulary and spelling.

  • (cs) in reply to J
    J:
    The Balance:
    Proscribe != Prescribe. They almost mean opposite things;

    "Following the proscribed steps" should have immediately seen Ray disciplined.

    Just like "compose" versus "comprise" - another common error.

    One more thing to write down in your exorcise book.

  • Aninnymouse (unregistered) in reply to Sizik
    Sizik:
    rous: Recursions of Unusual Size?

    Recursions of Unusual Size? I don't think they exist.

    CAPTCHA - Jugis: when Fezzik's looking for a rhyme and starts making up words

  • (cs) in reply to Reductio Ad Ridiculousum
    Reductio Ad Ridiculousum:
    Matt Westwood:
    TSF:
    Before billions was spent on wars of questionable necessity.

    Can we please keep the politics out of these articles?

    Why? Is the truth too challenging for you?

    You and I and we and they may or may not agree with the politics. There's enough sites out there that are polluted with politics. Let's keep this site focused on its main purpose: lambasting the failures of submitters and editors to execute correct grammar, vocabulary and spelling.
    :-) ... but boring.

  • (cs)

    Don't try to bait a flamewar.

    “If you think health care is expensive now, wait until you see what it costs when it's free.” ― P.J. O'Rourke

  • Reductio Ad Ridiculousum (unregistered) in reply to chubertdev
    chubertdev:
    Don't try to bait a flamewar.

    “If you think health care is expensive now, wait until you see what it costs when it's free.” ― P.J. O'Rourke

    P'haps yes, p'haps no. I don't know, though, of anyone outside of congress that's been able to manage that.

  • i❦ssl (unregistered) in reply to nonpartisan
    nonpartisan:
    The server was only MOSTLY down. It was a little up. When a server is completely down, there's only one thing you can do: take all its drives and look for interesting data.
    Servers have to be up to look for interesting data.

    If the server's down, hit the power switch.

  • Iggy (unregistered) in reply to Shan

    Yes, you are right, i made i mistake in the for loop, the project was done over 10 years ago, so i don't have the original code anymore.

    but using the code as part of an interview is actually a good idea.

    and the execution of a for loop depends on the optimization level you use. if switched off the loop gets executed even without modification of i within it.

    PS: you are free to use my wtf mistake in the "not working fork bomb"

Leave a comment on “All Your RAM Are Belong to Us”

Log In or post as a guest

Replying to comment #:

« Return to Article