Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 3, 2004, 05:53 PM   #1
MacNeXT
macrumors 6502
 
Join Date: Jun 2004
Java: catching stack overflow / sigbus error

Hi

I'm writing a piece of software in which it would be convenient to catch a stack overflow error. I know a stack overflow can be considered to be a very bad thing, especially in Java, but it's a natural phenomenon in this case. If you want to know why, let me know, but I'll stick to the subject in case no one cares.

The problem is that I sometimes get a stack overflow, which is the expected behavior, but in many other cases I get:

"Executable “java” has exited due to signal 10 (SIGBUS)."

This means that the operating system shut down the JVM because it did something illegal. Obviously, this is not acceptable, you can't catch this within Java. Is this a bug in Apple's JVM port? What does "signal 10 (SIGBUS)" mean?

Has anyone seen this before? Unfortunately, I haven't got access to a Windows or Linux system right now, so I can't find out how their JVM ports react in this case.

Any insight is appreciated.
__________________
Oh, and by the way, Micro$oft suxorz!!!
MacNeXT is offline   0 Reply With Quote
Old Dec 3, 2004, 07:21 PM   #2
broken_keyboard
Banned
 
broken_keyboard's Avatar
 
Join Date: Apr 2004
Location: Secret Moon base
It seems like the JVM itself is crashing. If that's the case you can't catch the error in Java since how can your Java program exist without the JVM? (in a runtime sense)

You can increase the stack of the JVM process itself like so:
ulimit -s 16384

Or you can increase the stack of the Java program with the -Xss command line option to java I think. I had to use this once when I had a recursive function that went a bit too deep...
broken_keyboard is offline   0 Reply With Quote
Old Dec 3, 2004, 07:37 PM   #3
MacNeXT
Thread Starter
macrumors 6502
 
Join Date: Jun 2004
Quote:
Originally Posted by broken_keyboard
It seems like the JVM itself is crashing. If that's the case you can't catch the error in Java since how can your Java program exist without the JVM? (in a runtime sense)

You can increase the stack of the JVM process itself like so:
ulimit -s 16384

Or you can increase the stack of the Java program with the -Xss command line option to java I think. I had to use this once when I had a recursive function that went a bit too deep...
Yes, as I mentioned too, the OS exits the JVM, and ofcourse there is nothing in Java to catch when the Java Virtual Machine doesn't exist anymore. I will look into your suggestions on how to increase the stack, thanks, but I don't consider that to be a solution to the problem. The problem is: Why the hell does the JVM crash in such a horrendous way? Looks like a bug to me.
__________________
Oh, and by the way, Micro$oft suxorz!!!
MacNeXT is offline   0 Reply With Quote
Old Dec 3, 2004, 10:04 PM   #4
broken_keyboard
Banned
 
broken_keyboard's Avatar
 
Join Date: Apr 2004
Location: Secret Moon base
You may want to check out the Java Bug Parade at Sun's website and post your bug.
broken_keyboard is offline   0 Reply With Quote
Old Dec 6, 2004, 11:05 AM   #5
jeremy.king
macrumors 603
 
jeremy.king's Avatar
 
Join Date: Jul 2002
Location: Fox Lake, IL
Quote:
Originally Posted by MacNeXT
Yes, as I mentioned too, the OS exits the JVM, and ofcourse there is nothing in Java to catch when the Java Virtual Machine doesn't exist anymore. I will look into your suggestions on how to increase the stack, thanks, but I don't consider that to be a solution to the problem. The problem is: Why the hell does the JVM crash in such a horrendous way? Looks like a bug to me.
Depends on your code. Anyone can write code to crash a JVM with stack overflows. Have you tried profiling and debugging using Eclipse or something similar? Are you using any recursion or have an absurd amount of method nesting? Are you using JNI to call other non-java libraries?

Another way to increase the JVM stack (can't say I have used broken's method) is to use the -Xss flag on your java command.

For example: -Xss10m or -Xss512k
jeremy.king is offline   0 Reply With Quote
Old Dec 7, 2004, 08:06 AM   #6
MacNeXT
Thread Starter
macrumors 6502
 
Join Date: Jun 2004
Quote:
Originally Posted by kingjr3
Depends on your code. Anyone can write code to crash a JVM with stack overflows. Have you tried profiling and debugging using Eclipse or something similar? Are you using any recursion or have an absurd amount of method nesting? Are you using JNI to call other non-java libraries?

Another way to increase the JVM stack (can't say I have used broken's method) is to use the -Xss flag on your java command.

For example: -Xss10m or -Xss512k
It's not direct recursion. It's more like A calls B calls C calls A calls B ... (oversimplified). It's also a mixture of static methods and instance methods. But what do you mean with "crash a JVM with stack overflows"? I can't find evidence that a stack overflow is something that cannot be caught in some cases, it should be possible to handle this. It should not crash the JVM. Unlike for example an Out of Memory error, which cannot be caught.

It still looks like a bug to me.
__________________
Oh, and by the way, Micro$oft suxorz!!!
MacNeXT is offline   0 Reply With Quote
Old Dec 7, 2004, 09:18 AM   #7
FritzTheWonderM
macrumors member
 
Join Date: Dec 2003
Location: Planet 10
Quote:
Originally Posted by MacNeXT
It still looks like a bug to me.
Does this help?:

http://lists.apple.com/archives/java.../msg00129.html
FritzTheWonderM is offline   0 Reply With Quote
Old Dec 7, 2004, 10:27 AM   #8
jeremy.king
macrumors 603
 
jeremy.king's Avatar
 
Join Date: Jul 2002
Location: Fox Lake, IL
Quote:
Originally Posted by MacNeXT
But what do you mean with "crash a JVM with stack overflows"?
Sounds more like a code issue to me. You are so quick to blame the JVM. Have you tried Profiling your application?

See http://www.geocities.com/herong_yang/jvm/stack.html

ALthough JVMs have improved since 2002, I would venture to guess these simple programs are still effective at crashing a JVM.

Aside - Worth a shot, but wrap your code with a try/catch and instead of catching Exception, catch Throwable.
jeremy.king is offline   0 Reply With Quote
Old Dec 7, 2004, 10:48 AM   #9
FritzTheWonderM
macrumors member
 
Join Date: Dec 2003
Location: Planet 10
Quote:
Originally Posted by kingjr3
Aside - Worth a shot, but wrap your code with a try/catch and instead of catching Exception, catch Throwable.
Good point. Also, try running the same code on different JVMs if possible. If it doesn't explode on the Windows or Linux 1.4.2_xx JVM or maybe a 1.3 JVM it's probably Apple's problem.
FritzTheWonderM is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Java error Appl3FTW MacBook Pro 3 Aug 21, 2013 06:53 PM
SIGBUS ERROR w/ Acrobat Pro XI on OS 10.8 drivord OS X 10.8 Mountain Lion 0 Jun 18, 2013 08:19 AM
General: How-to-Fix TinyUmbrella Java Error 5.11.00 and above. SmartiOS Jailbreaks and iOS Hacks 1 Oct 20, 2012 04:15 AM
KOTOR crashing and SIGBUS error sarajaade Mac Applications and Mac App Store 0 Jul 6, 2012 12:48 AM
Java Update unsigned application error jamroman Mac Programming 4 Jun 22, 2012 11:56 AM

Forum Jump

All times are GMT -5. The time now is 12:36 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC