Need experts suggestion

G

Gsec

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
 
V

Vladimir Oka

Gsec said:
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...
 
G

Gsec

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
 
R

Rod Pemberton

Gsec said:
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
 
P

pete

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 !;-)

gsec

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

OP is acting the clown.
 
G

Gsec

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
 
C

Chris Dollin

Gsec said:
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.
 
S

santosh

Gsec said:
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.
 
R

Richard Heathfield

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

Richard Heathfield

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

Vladimir Oka

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 !;-)

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

Vladimir Oka

Richard said:
Vladimir Oka said:


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

pete

Gsec said:
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.
 
S

santosh

Vladimir said:
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 ..."
 
R

Richard Tobin

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
 
P

pete

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top