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

StackOverflow exceptions/crashes not reported by Raygun #82

Open
rs146 opened this issue Aug 9, 2021 · 4 comments
Open

StackOverflow exceptions/crashes not reported by Raygun #82

rs146 opened this issue Aug 9, 2021 · 4 comments
Milestone

Comments

@rs146
Copy link

rs146 commented Aug 9, 2021

Hi,

We have noticed that Raygun doesn't seem to pick up any crashes caused by StackOverflow errors. For example, we have the following stack trace in our Play Console:

java.lang.StackOverflowError: 
  at androidx.core.view.ViewCompat.getLayoutDirection (ViewCompat.java:1558)
  at androidx.drawerlayout.widget.DrawerLayout.findDrawerWithGravity (DrawerLayout.java:986)
  at androidx.drawerlayout.widget.DrawerLayout.isDrawerOpen (DrawerLayout.java:1836)
  at com.mikepenz.materialdrawer.Drawer.isDrawerOpen (Drawer.java:153)
  at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:292)
  at xxx.yyy.zzz.FragmentNavigatorImpl.navigateBack (FragmentNavigatorImpl.kt:72)
  at xxx.yyy.zzz.MainActivity.navigateBack (MainActivity.kt:344)
  at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:310)
  at xxx.yyy.zzz.FragmentNavigatorImpl.navigateBack (FragmentNavigatorImpl.kt:72)
  at xxx.yyy.zzz.MainActivity.navigateBack (MainActivity.kt:344)
  at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:310)

However, these stack traces are not reported in Raygun. I can confirm we have set up/initialised the RaygunClient correctly using the following code in our Activity's onCreate() method:

RaygunClient.init(application)
RaygunClient.setVersion(BuildConfig.VERSION_NAME)
RaygunClient.enableCrashReporting()
RaygunPageTags.init(deviceType)
RaygunClient.enableRUM(this)

Is there anything that could be preventing Raygun from reporting these StackOverflow crashes?

Version ussed: 4.0.1

Thank you for your support.

@TheRealAgentK
Copy link
Contributor

@rs146 Is it only StackOverflowErrors you're missing?

Would you have a reproducible case that triggers this?

@rs146
Copy link
Author

rs146 commented Aug 10, 2021

Hi @TheRealAgentK - yes it's only StackOverflow Errors that we are missing. I can confirm we are receiving all other crash logs.

The StackOverflow case in the above example occurs in this scenario/use-case - when a user presses the Back button on the device. (The following code snippet has been shortened for clarity). In an Activity, override the onBackPressed() function with the below code:

override fun onBackPressed() {
     onBackPressed()
}

Although the logic is much more complex in our codebase - however, this is the core issue of the StackOverflow error that we have seen; but not reported in our Raygun logs.

If this appears in Raygun, another option would be to do the following:

class MainActivity {
     val someWorker = SomeWorker()

     override fun onBackPressed() {
            someWorker.doWork(this)
     }
}

class SomeWorker {
      fun doWork(activity: Activity) {
             activity.onBackPressed()
      }
}

@TheRealAgentK TheRealAgentK self-assigned this May 2, 2022
@TheRealAgentK
Copy link
Contributor

The core issue here seems to be that when a StackOverflowError occurs, we're essentially dealing with a VirtualMachineError that almost instantly crashes the virtual machine on the device before our hook into the unhandled exception tracker can even kick in - exaggerated by a lack of stack frames because of the StackOverflowError.

Anecdotally some people had some success in catching this by re-throwing any VirtualMachineError as a more specialized exception, but that avenue will require some further exploration and it's currently unclear if that's a generally applicable solution.

This will be addressed in work for a new release.

@TheRealAgentK TheRealAgentK added this to the 5.0 milestone May 2, 2022
@TheRealAgentK TheRealAgentK removed their assignment Jul 3, 2024
@TheRealAgentK
Copy link
Contributor

Some more observations: The process simply dies before the payload is put into the posting services to be processed.

Some directions to investigate:

  1. In case of terminal issues like SOE, try to write to file instead (need to check if that completes) so that it will be picked up at restart and sent

  2. Delay process termination in UncaughtExceptionHandler, uncertain if that actually works and if that is a suitable and appropriate action. Might need to make it configurable if going down this parh.

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

2 participants