Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceur causing StackOverflowError on too complex CompositeException #4

Open
mkoslacz opened this issue Jul 1, 2017 · 2 comments
Open

Comments

@mkoslacz
Copy link

mkoslacz commented Jul 1, 2017

Hi,

Recently I have encountered a problem using Traceur on Android.

In my project I sometimes got OOM errors when trying to log too complex CompositeExceptions from external components using Android Log.e method. To avoid it I strip these exceptions to have 5 original exceptions max using stripCompositeException method included in the gist I linked at the end of this issue.

In the regular setup this approach works correctly, but using Traceur, on less performant devices and older apis that have older memory management alghoritms (in my case API 17) I got uncaught StackOverflowError that crashes my app. I include the error I'm encountering in the attached test case:

07-01 12:42:09.746 2489-2489/pl.videostar E/AndroidRuntime: FATAL EXCEPTION: main
                                                            java.lang.StackOverflowError
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:71)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:73)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:73)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:73)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:73)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onSubscribe(ObservableDoOnEach.java:73)
                                                                at io.reactivex.internal.observers.BasicFuseableObserver.onSubscribe(BasicFuseableObserver.java:66)
                                                                at io.reactivex.internal.operators.observable.ObservableJust.subscribeActual(ObservableJust.java:34)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssemblyScalarCallable.subscribeActual(ObservableOnAssemblyScalarCallable.java:40)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                                at com.tspoon.traceur.ObservableOnAssembly.subscribeActual(ObservableOnAssembly.java:43)
                                                                at io.reactivex.Observable.subscribe(Observable.java:10842)
                                                            	at io.reactivex.internal.operators.observable.ObservableDoOnEach.su

Although, on API 25 Traceur won't crash the app and will log the excepton correctly, but still, in such case the printed stacktrace is so huge that it fills up whole Android Logcat console and eventually breaks it withread: unexpected EOF! what also makes logging useless.

Is it possible to create some constraints in Traceur that would prevent such issues?

I have created the test case here. Let me know if you wouldn't be able to reproduce the issue.

@T-Spoon
Copy link
Owner

T-Spoon commented Aug 13, 2017

Hey!

Not in a dev environment at the moment - but there is TraceurConfig. SHOW_ONLY_FIRST - which will append only a single exception. Might be suitable for your use case (but could potentially remove a lot of useful info)

It would be better to be able to customise this behaviour more though - potentially by supplying a custom function to determine whether or not an exception should be appended to the stacktrace.

When I get a chance I'll take a look at implementing this!

@5upernaut
Copy link

Hi! Great library! It looks like it's not possible to set the LogLevel to SHOW_ONLY_FIRST, or did I miss something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants