question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StackOverflowError is swallowed

See original GitHub issue

The 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:closed
  • Created 10 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
duartencommented, Jan 16, 2014

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.

0reactions
benjchristensencommented, Feb 8, 2014
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found