Need experts suggestion

Discussion in 'C Programming' started by Gsec, May 26, 2006.

  1. Gsec

    Gsec Guest

    Hi,

    Can anybody let me know how to write a infinite loop, such that the
    program never crashes ?

    I, guess, buffer overflow method mite help!Not sure.

    Plz let me know.

    -thanks and regards,

    Gsec
     
    Gsec, May 26, 2006
    #1
    1. Advertising

  2. Gsec

    Vladimir Oka Guest

    Gsec wrote:
    > Hi,
    >
    > Can anybody let me know how to write a infinite loop, such that the
    > program never crashes ?


    Pick your poison:

    for ( ; ; ) { /* whatever */ }
    while ( 1 ) { /* whatever */ }
    do { /* whatever */ } while ( 1 );

    inf_label:
    /* whatever */
    goto inf_label;

    Of course you have to make sure that { /* whatever */ } does not
    crash.

    > I, guess, buffer overflow method mite help!Not sure.


    I don't know what buffer overflow has to do with infinte loop. I'm even
    more baffled by mites.

    > Plz let me know.


    Oh, sorry. I didn't realise you wanted Plz to help you. Oh, well...
     
    Vladimir Oka, May 26, 2006
    #2
    1. Advertising

  3. Gsec

    Gsec Guest

    Hi,

    Thanks;-). But, I don't think, any one will do. Try it first, then if
    it doesn't crash after one week (;-) ), let me know !;-)

    gsec
    Vladimir Oka wrote:
    > Gsec wrote:
    > > Hi,
    > >
    > > Can anybody let me know how to write a infinite loop, such that the
    > > program never crashes ?

    >
    > Pick your poison:
    >
    > for ( ; ; ) { /* whatever */ }
    > while ( 1 ) { /* whatever */ }
    > do { /* whatever */ } while ( 1 );
    >
    > inf_label:
    > /* whatever */
    > goto inf_label;
    >
    > Of course you have to make sure that { /* whatever */ } does not
    > crash.
    >
    > > I, guess, buffer overflow method mite help!Not sure.

    >
    > I don't know what buffer overflow has to do with infinte loop. I'm even
    > more baffled by mites.
    >
    > > Plz let me know.

    >
    > Oh, sorry. I didn't realise you wanted Plz to help you. Oh, well...
     
    Gsec, May 26, 2006
    #3
  4. "Gsec" <> wrote in message
    news:...
    > Hi,
    >
    > Can anybody let me know how to write a infinite loop, such that the
    > program never crashes ?
    >
    > I, guess, buffer overflow method mite help!Not sure.
    >
    > Plz let me know.


    I take it that you want to insert code in the infinite loop? And, you'd
    like the unmentioned code to recover from whatever fault may be generated?
    I'm supposing that is you intended to ask...

    If so, you need to look at:
    1) setjmp(), jmpto() and jmpbuf[] to restore as much as possible of the
    pre-fault execution context
    2) signal() for turning off signals, by setting SIGBREAK (or SIGQUIT),
    SIGINT, and SIGABRT to SIG_IGN
    3) turning off any Ctrl-C or Ctrl-break handling, using some non-standard
    function, like setcbrk() or break_off()


    Rod Pemberton
     
    Rod Pemberton, May 26, 2006
    #4
  5. Gsec

    pete Guest

    Gsec wrote:
    >
    > Hi,
    >
    > Thanks;-). But, I don't think, any one will do. Try it first, then if
    > it doesn't crash after one week (;-) ), let me know !;-)
    >
    > gsec
    > Vladimir Oka wrote:
    > > Gsec wrote:
    > > > Hi,
    > > >
    > > > Can anybody let me know how to write a infinite loop,
    > > > such that the
    > > > program never crashes ?

    > >
    > > Pick your poison:
    > >
    > > for ( ; ; ) { /* whatever */ }
    > > while ( 1 ) { /* whatever */ }
    > > do { /* whatever */ } while ( 1 );
    > >
    > > inf_label:
    > > /* whatever */
    > > goto inf_label;
    > >
    > > Of course you have to make sure that { /* whatever */ } does not
    > > crash.
    > >
    > > > I, guess, buffer overflow method mite help!Not sure.

    > >
    > > I don't know what buffer overflow has to do with infinte loop.


    Buffer overflow has nothing to do with infinte loop,
    as I'm sure you know.

    OP is acting the clown.

    --
    pete
     
    pete, May 26, 2006
    #5
  6. Gsec

    Gsec Guest

    Hi Pemb,

    Thanks. Sorry that my question was not that clear before. Well let me
    make the picture very clear. My question is from Stack overflow point
    of view.If you write an infinite loop simply, it will crash after some
    time. Similarly, if we call main() within main (),
    it will crash after some time definitely due to stack overflow !

    So, I think that the buffer overflow method will let me my program to
    execute on an infinite way, with no SIGSEGV.

    I hope, now you can let me know more information on my query.

    Thanks.

    Gsec
     
    Gsec, May 26, 2006
    #6
  7. Vladimir Oka said:

    > I'm even more baffled by mites.


    There are powders you can get...

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, May 26, 2006
    #7
  8. Gsec

    Chris Dollin Guest

    Gsec wrote:

    > Hi Pemb,
    >
    > Thanks. Sorry that my question was not that clear before. Well let me
    > make the picture very clear. My question is from Stack overflow point
    > of view.If you write an infinite loop simply, it will crash after some
    > time.


    What makes you think `while (1) {}` will ever crash?

    > Similarly, if we call main() within main (),
    > it will crash after some time definitely due to stack overflow !


    You think so?

    int main(void) { return main(); }

    need not crash.

    <fx:codingHappens/>

    Make that "does not crash".

    > So, I think that the buffer overflow method will let me my program to
    > execute on an infinite way, with no SIGSEGV.


    I have this feeling you're not asking the question you mean to ask.

    --
    Chris "gcc -O4 main.c; ./a.out" Dollin
    "We did not have time to find out everything we wanted to know." /A Clash of Cymbals/
     
    Chris Dollin, May 26, 2006
    #8
  9. Gsec

    santosh Guest

    Gsec wrote:
    > Hi Pemb,
    >
    > Thanks. Sorry that my question was not that clear before. Well let me
    > make the picture very clear. My question is from Stack overflow point
    > of view.


    The C langauge does not define stacks.

    > If you write an infinite loop simply, it will crash after some
    > time. Similarly, if we call main() within main (),
    > it will crash after some time definitely due to stack overflow !


    I think you're confusing a recursive function call from an infinite
    loop. The former will likely crash after sometime while the latter
    should not.

    > So, I think that the buffer overflow method will let me my program to
    > execute on an infinite way, with no SIGSEGV.


    Buffer overflow has nothing to do with infinite loops.
     
    santosh, May 26, 2006
    #9
  10. Gsec said:

    > Hi,
    >
    > Thanks;-). But, I don't think, any one will do. Try it first, then if
    > it doesn't crash after one week (;-) ), let me know !;-)


    I have had an infinite loop under test since the beginning of March. So far,
    we're looking good - but it's early days yet.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, May 26, 2006
    #10
  11. Gsec said:

    > So, I think that the buffer overflow method will let me my program to
    > execute on an infinite way, with no SIGSEGV.


    It's more likely to have the opposite effect. The way to avoid segfaults in
    your program is to write the code properly.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, May 26, 2006
    #11
  12. Gsec

    Vladimir Oka Guest

    Gsec wrote:
    > Vladimir Oka wrote:
    > > Gsec wrote:
    > > > Hi,
    > > >
    > > > Can anybody let me know how to write a infinite loop, such that the
    > > > program never crashes ?

    > >
    > > Pick your poison:
    > >
    > > for ( ; ; ) { /* whatever */ }
    > > while ( 1 ) { /* whatever */ }
    > > do { /* whatever */ } while ( 1 );
    > >
    > > inf_label:
    > > /* whatever */
    > > goto inf_label;
    > >
    > > Of course you have to make sure that { /* whatever */ } does not
    > > crash.
    > >
    > > > I, guess, buffer overflow method mite help!Not sure.

    > >
    > > I don't know what buffer overflow has to do with infinte loop. I'm even
    > > more baffled by mites.
    > >
    > > > Plz let me know.

    > >
    > > Oh, sorry. I didn't realise you wanted Plz to help you. Oh, well...

    > Hi,
    >
    > Thanks;-). But, I don't think, any one will do. Try it first, then if
    > it doesn't crash after one week (;-) ), let me know !;-)


    Don't top post. I've fixed it here.

    Why would those infinite loops crash? Please explain.

    I'm sure that this:

    int main(void)
    {
    for ( ; ; )
    ;
    }

    has no reason whatsoever to crash. Your PC may crash for other reasons
    (say, if you drop it on the floor), but not because of anythingin the
    program above.
     
    Vladimir Oka, May 26, 2006
    #12
  13. Gsec

    Vladimir Oka Guest

    Richard Heathfield wrote:
    > Vladimir Oka said:
    >
    > > I'm even more baffled by mites.

    >
    > There are powders you can get...


    Baffled, not infested. ;-)

    OP might be though. He may be scratching so much that he knock his PC
    to the floor, where it then crashes and stops his infinite loops.
     
    Vladimir Oka, May 26, 2006
    #13
  14. Gsec

    pete Guest

    [ot]Re: Need experts suggestion

    Richard Heathfield wrote:
    >
    > Vladimir Oka said:
    >
    > > I'm even more baffled by mites.

    >
    > There are powders you can get...


    There's also mites you can buy, that eat other mites.

    http://www.zone10.com/tech/mites/mites_gb.htm

    --
    pete
     
    pete, May 26, 2006
    #14
  15. Gsec

    pete Guest

    Gsec wrote:
    >
    > Hi Pemb,
    >
    > Thanks. Sorry that my question was not that clear before. Well let me
    > make the picture very clear. My question is from Stack overflow point
    > of view.If you write an infinite loop simply, it will crash after some
    > time.


    It won't.

    > I hope, now you can let me know more information on my query.


    You're wrong.

    --
    pete
     
    pete, May 26, 2006
    #15
  16. Gsec

    santosh Guest

    Vladimir Oka wrote:
    > Gsec wrote:
    > > Gsec wrote:
    > > > Hi,
    > > >
    > > > Can anybody let me know how to write a infinite loop, such that the
    > > > program never crashes ?

    .... snip ...
    > > Thanks;-). But, I don't think, any one will do. Try it first, then if
    > > it doesn't crash after one week (;-) ), let me know !;-)

    >
    > Don't top post. I've fixed it here.
    >
    > Why would those infinite loops crash? Please explain.


    I think the OP is confusing the difference between a simple infinite
    loop and infinitly recursive function calls. The latter would probably
    crash. Amazingly, he seems to believe precipitating a buffer overflow
    will prevent such a crash.

    This is the result of reading cheap books whose titles usually begin
    with "Hacking ..."
     
    santosh, May 26, 2006
    #16
  17. Gsec

    Jordan Abel Guest

    On 2006-05-26, Richard Heathfield <> wrote:
    > Gsec said:
    >
    >> Hi,
    >>
    >> Thanks;-). But, I don't think, any one will do. Try it first, then if
    >> it doesn't crash after one week (;-) ), let me know !;-)

    >
    > I have had an infinite loop under test since the beginning of March. So far,
    > we're looking good - but it's early days yet.


    Isn't it always?
     
    Jordan Abel, May 26, 2006
    #17
  18. Gsec

    Vladimir Oka Guest

    Re: [ot]Re: Need experts suggestion

    pete wrote:
    > Richard Heathfield wrote:
    > >
    > > Vladimir Oka said:
    > >
    > > > I'm even more baffled by mites.

    > >
    > > There are powders you can get...

    >
    > There's also mites you can buy, that eat other mites.
    >
    > http://www.zone10.com/tech/mites/mites_gb.htm


    LoL. I loved the section named "Arrival and Deployment of your troops".
    ;-)
     
    Vladimir Oka, May 26, 2006
    #18
  19. In article <>,
    Vladimir Oka <> wrote:
    >I'm sure that this:
    >
    > int main(void)
    > {
    > for ( ; ; )
    > ;
    > }
    >
    >has no reason whatsoever to crash. Your PC may crash for other reasons
    >(say, if you drop it on the floor), but not because of anythingin the
    >program above.


    I have a computer at home that will crash after about five minutes of
    running that program.

    -- Richard
     
    Richard Tobin, May 26, 2006
    #19
  20. Gsec

    pete Guest

    Richard Tobin wrote:
    >
    > In article <>,
    > Vladimir Oka <> wrote:
    > >I'm sure that this:
    > >
    > > int main(void)
    > > {
    > > for ( ; ; )
    > > ;
    > > }


    > I have a computer at home that will crash after about five minutes of
    > running that program.


    Why do you think that happens?

    Does it overheat?
    I've worked with computers that were inadequately ventilated,
    that crashed after several hours,
    but not always the same amount of hours.
    The programmers couldn't figure that one out.
    They had to get the company "smart guy" to figure that one out.

    --
    pete
     
    pete, May 26, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AW
    Replies:
    0
    Views:
    326
  2. samir dsf
    Replies:
    0
    Views:
    341
    samir dsf
    Jan 27, 2006
  3. Santa
    Replies:
    2
    Views:
    427
    Roedy Green
    Jan 8, 2004
  4. Need experts opnion

    , Jan 5, 2006, in forum: C Programming
    Replies:
    18
    Views:
    464
    Richard Bos
    Jan 10, 2006
  5. perry.yuan
    Replies:
    9
    Views:
    341
Loading...

Share This Page