StackOverflowError is swallowed
See original GitHub issueThe following code should have thrown StackOverflowError:
final PublishSubject<Integer> a = PublishSubject.create();
final PublishSubject<Integer> b = PublishSubject.create();
a.subscribe(new Observer<Integer>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer args) {
System.out.println(args);
}
});
b.subscribe(new Observer<Integer>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer args) {
System.out.println(args);
}
});
a.subscribe(new Observer<Integer>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer args) {
b.onNext(args + 1);
}
});
b.subscribe(new Observer<Integer>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer args) {
a.onNext(args + 1);
}
});
a.onNext(1);
However, StackOverflowError is swallowed. The problem is the following line in SafeObserver: https://github.com/Netflix/RxJava/blob/0b1b6e7a91d89ad63263b80747f0bd4683fe4ba2/rxjava-core/src/main/java/rx/operators/SafeObserver.java#L117
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
When StackOverflowError is thrown, there is few stack space. However, this line will generate too big stack frame and cause the thread crash. If I comment out this line, I can observe StackOverflowError.
Reported by Samuel at https://groups.google.com/forum/#!topic/rxjava/eraZ-32w1gQ
Issue Analytics
- State:
- Created 10 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
java - Exception is swallowed by finally - Stack Overflow
The finally block executes no matter what exception is thrown. It doesn't just execute after the exceptions are caught by the catch blocks...
Read more >StackOverflowError and Threads Waiting for ... - Poonam Parhar
I got to analyze such a situation recently. The threads in the application were reported to be Stuck. They were waiting for a ......
Read more >Issue 2258: StackOverflowError stacktrace is eaten up by Jython
I had a bug in Java code that resulted in a stack overflow. However, this code was called from Jython, so the only...
Read more >Exceptions (RxJava Javadoc 2.2.21) - ReactiveX
Parameters: t - the Throwable to test and perhaps throw; See Also: RxJava: StackOverflowError is swallowed (Issue #748). Skip navigation links.
Read more >[LOGBACK-1454] StackOverflow error - QOS.ch JIRA
But logger.error("Error", e) results in a StackOverflowError thrown at the logging site, swallowing the original exception: java.lang.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, my point is that users may not be expecting to be handed such exception, and may swallow them themselves, by for example just logging them. The correct behaviour, IMHO, would be to let them bring down the JVM asap.
Should be fixed in https://github.com/Netflix/RxJava/pull/839