Results 1 to 3 of 3

Thread: loop to deliberately cause program to crash?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    loop to deliberately cause program to crash?

    Code:
    class GamePlayer {
        int doSomeMove() {
    	// for loop put in here deliberately to cause timeout
    	for (;;) {
    	}
    
    	return 5;
        }
    }
    i'm trying to test my system with timeouts and stuff, by doing malicious coding on purpose. but the above doesn't work anyway as it says
    Test.java:40: unreachable statement
    return 5;
    ^
    1 error

    how could i make this work to test stuff?

  2. #2
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782

    Re: loop to deliberately cause program to crash?

    Make a boolean that's true then have a while loop with the boolean as its parameter.
    C#.net, VB, C++, Java, VS 2005/2008
    Dont' forget to rate posts that are helpful to you.

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: loop to deliberately cause program to crash?

    Quote Originally Posted by Steve_F
    Make a boolean that's true then have a while loop with the boolean as its parameter.
    Let it be a class member, and make sure it's neither const nor final
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width