-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
crash can not be captured on windows #818
Comments
Hi @chenxinhua2021! I need more context because I am not well-versed in Flutter. Especially the following questions immediately pop up in my head:
What I can tell you:
|
Thank you very much for your fast reply @supervacuus . I use dart sdk and native sdk in my flutter application. |
When you say "other crashes can be captured", do you mean dart crashes or other native crashes (like an access violation) from an FFI module? I guess any other SEH exception from an FFI module would also not be reported. I cannot tell you when I will have time to investigate this further, but it is on our agenda. |
Yes, any other SEH exception from an FFI module is not reported. Other crashes Which is maked by c++ plugin to be called by flutter can be captured. I will try to do a simple demo to present the problem. |
Ok, thanks for verifying. So the C++ FFI aspect seems to be a red herring in this issue since C++ exceptions on Windows are just SEH exceptions. If SEH exceptions fail to report, the problem lies with the registration or the execution environment of the unhandled exception filter in our backend because Dart installs one itself during the startup of the runtime. This filter would normally print a stack trace if there was a native crash. The Native SDK in turn would overwrite that filter with its backend-specific implementation. Can you compare whether crashing from the FFI module prints a stack trace without initializing the Native SDK? |
I try to use windows system api (SetUnhandledExceptionFilter), crash can not be captured which is maked c++ code which is called FFI module. Stack information can be printed in visual studio tool when crash from ffi module. |
Hi @supervacuus we make a simple demo to present the problem. this is url. https://github.com/Arctuition/dart-ffi-crash |
Thank you for preparing a repro that covers the FFI and plugin case, @chenxinhua2021. As I said before, I cannot say when I will have the time to dive into this. @marandaneto, I think you will be involved in the dart/native evaluation, right? @chenxinhua2021 prepared a repro-repo, that fails at capturing SEH from FFI modules but is successful when crashing in Flutter plugins. Even if this is not actionable for you rn, I think the Dart-SDK team should be aware of this issue. I will try to figure out where in the FFI boundary the exception propagation fails and if we can even do something about it from the Native SDK. |
Thank you very much for your reply @supervacuus . I have consulted on drak sdk, some reply may be is worthy for you. |
That's correct, it's not a supported use case yet, and apparently, there's a dependency with dart-lang/sdk#51726 (comment) and its exception filters. |
Hi @marandaneto, yes, that is why I hooked you in. You will experience the same issue with any native code called from Dart-generated code (it happens with JIT and AOT). As mentioned here, it is not specific to FFI modules (though it will mostly be an issue there) but related to unwinding the Dart code regions in case of a crash on Windows. |
@chenxinhua2021 did you manage to make this work in the end? I see that dart team fixed the underlying issue. |
+1 this would be great ty to Sentry team |
To be clear, @isaacy13: the issue had to be fixed in Dart itself and not in Sentry's SDKs. The fix was released with Dart 3.0.0-422.0.dev. The implementation for Windows ARM64 still needs to be completed. We only keep this issue open as a test target to consider for Windows Desktop support in the Dart SDK. As far as we know, there is nothing to do on the side of the Native SDK to allow crash reporting for Windows native code as long as you deploy to a Dart environment with the above fix. cc @kahest |
Ah perfect, thank you @supervacuus for the clarification Perhaps this belongs in another ticket (not sure if Dart or Sentry), but whenever FFI C++ code is calling Sometimes I don't even get the For context: media-kit/media-kit#743
I've previously done Sentry quick setup & verified logs do show up when following these steps Also, Sentry is initialized before the exceptions are thrown |
@isaacy13 I'm seeing the same behavior (i.e. no information in sentry dashboard on C++ crashes), but from what I understand this is expected behavior. You would need to integrate the Sentry Native like @chenxinhua2021 in this example if you want to have that work. I wanted to try this myself but I'm afraid I don't have the time right now, even if it looks like most of the work has been done in that example. Let me know if you try it. p.s. don't expect native crashes to be reported instantaneously like other flutter exceptions, they only show up after you reopen the app after the crash |
@alexvoina Thanks for the info After re-reading with a fresher pair of eyes, my understanding has changed As @supervacuus said previously, the Dart team fixed the issue from @chenxinhua2021's post (dart-lang/sdk#51726)
I suspect the thing I'm missing is initializing Sentry in C++ -- I am currently only initializing Sentry in Flutter
But with my current understanding of the various threads, it sounds like things should be working, just need to give it another shot -- I expect to report back to this thread this weekend or the next with results |
Yes, that's right. The Native SDK and the Dart SDK are not yet integrated for Flutter on Windows (getsentry/sentry-dart#896). The Native SDK can detect any unhandled crash outside the managed environment, while the Dart SDK will report errors from within Dart/Flutter, such as exceptions or failed assertions. The latter will be enough for most Flutter Applications, but when using native libraries via Dart's FFI or as Flutter plugins, you might need a native crash handler. For most supported platforms of the Dart SDK, these native crash handlers are already integrated (for instance, on Android, you will get NDK crashes reported via
There is currently no indication that the Native SDK and the Dart SDK can't operate next to each other (they won't cooperate, you will have to initialize them separately, and scope changes will not be synced). |
@isaacy13 really looking forward to hearing your report |
A lot later than I expected to be replying -- but everything is working as expected Steps taken on Windows:
Now, whenever I throw an exception in plugin libraries' C++ code, I get the alert in Sentry! notes:
windows/runner/CMakeLists.txt
sentry_init.h
|
@isaacy13 it is never too late! Can't wait to try this myself too <3 Big thanks for all the explanations & code |
closing this now as resolved. related PR for sentry-native integration: getsentry/sentry-dart#2286 |
I am using flutter to develop app. and use sentry to capture crash. C PlusPlus code is called by ffi which is manged by dart in flutter. Now, The crash is not captured in c plusplus code, try to use crashpad/breakpad/inproc backend, fail to capture the crash.
Found The issue which is in the dart website. dart-lang/sdk#39140
FFI is only a C-based. Maybe c plus plus exceptions can not be captured. Is that why Crash can not be captured by sentry ?
If i want to capture the crash, which methods can be used ?
The text was updated successfully, but these errors were encountered: