How to stop StackOverflowError

T

Thomas Jollans

Hi group!

when i run my test program i get a stachoverflowerror. why do i get
this? how do i stop it?

thanx in advance for any help given,
thomas
 
N

Neil Campbell

Thomas said:
Hi group!

when i run my test program i get a stachoverflowerror. why do i get
this? how do i stop it?

thanx in advance for any help given,
thomas

It sometimes suggests that your program is recursing infinitely. Can you
post any code which demonstrates the problem?
 
T

Thomas Jollans

Neil said:
Thomas Jollans wrote:




It sometimes suggests that your program is recursing infinitely. Can you
post any code which demonstrates the problem?

part of static main(String[]) code:

BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
for(;;)
{
String cmd = r.readLine();
if(cmd.equals("quit"))
{
l.stop();
System.exit(0);
}
try
{
p.sendInt(java.net.InetAddress.getByName(args[3]),
78010, Integer.decode(cmd).intValue(), true);
}
catch(NumberFormatException nfe)
{
}
}


p and l are objects of self-written classes.
p.sendInt calls another function, which in turn calls another(in l),
which constructs a socket and passes it thru to p which uses it. I don't
think there's any hidden recursion in there?

thomas
 
T

Thomas Jollans

Thomas said:
Neil said:
Thomas Jollans wrote:





It sometimes suggests that your program is recursing infinitely. Can you
post any code which demonstrates the problem?

part of static main(String[]) code:

BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
for(;;)
{
String cmd = r.readLine();
if(cmd.equals("quit"))
{
l.stop();
System.exit(0);
}
try
{
p.sendInt(java.net.InetAddress.getByName(args[3]),
78010, Integer.decode(cmd).intValue(), true);
}
catch(NumberFormatException nfe)
{
}
}


p and l are objects of self-written classes.
p.sendInt calls another function, which in turn calls another(in l),
which constructs a socket and passes it thru to p which uses it. I don't
think there's any hidden recursion in there?

thomas
oh, and it happened somewhere in the first iteration of the for loop.
 
N

Neil Campbell

Thomas said:
Neil said:
It sometimes suggests that your program is recursing infinitely. Can you
post any code which demonstrates the problem?

part of static main(String[]) code:
p and l are objects of self-written classes.
p.sendInt calls another function, which in turn calls another(in l),
which constructs a socket and passes it thru to p which uses it. I don't
think there's any hidden recursion in there?

I can't see anything here that's obviously causing the problem. Without
seeing what is happening in p and l I don't really know what to suggest,
sorry.

Perhaps you could put together a cut-down version of your program which
demonstrates the problem in as little code as possible, then it might be
easier to spot where it's going wrong.
 
S

Sudsy

Thomas Jollans wrote:
for(;;)
{
String cmd = r.readLine();

Probably not the problem, but you really should be checking
for end-of-file here. Add something like this:

if( cmd == null )
break;
 

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

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top