-
Notifications
You must be signed in to change notification settings - Fork 506
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
Gather callstack even if instruction pointer is null. #1303
Conversation
My manual test required changing some code in the editor, namely in the diff --git a/Runtime/Export/Diagnostics/DiagnosticsUtils.bindings.cpp b/Runtime/Export/Diagnostics/DiagnosticsUtils.bindings.cpp
index addee2b48877..b85b9233f569 100644
--- a/Runtime/Export/Diagnostics/DiagnosticsUtils.bindings.cpp
+++ b/Runtime/Export/Diagnostics/DiagnosticsUtils.bindings.cpp
@@ -17,6 +17,7 @@
#include <signal.h>
#endif
+extern void (*wtfFuncPtr)();
namespace DiagnosticsUtils_Bindings
{
@@ -28,10 +29,12 @@ namespace DiagnosticsUtils_Bindings
{
printf_console("Forcing a crash -- Intentionally Dereferencing NULL pointer\n");
#if UNITY_POSIX
- raise(SIGSEGV);
+ //raise(SIGSEGV);
+ wtfFuncPtr();
#elif PLATFORM_WIN
RaiseException(EXCEPTION_ACCESS_VIOLATION, NULL, NULL, NULL);
#else
+ wtfFuncPtr();
int* p = NULL;
*p = 5;
#endif
diff --git a/Runtime/Export/Unsafe/UnsafeUtility.bindings.cpp b/Runtime/Export/Unsafe/UnsafeUtility.bindings.cpp
index 75f89d167bea..c3e9af2ce8b3 100644
--- a/Runtime/Export/Unsafe/UnsafeUtility.bindings.cpp
+++ b/Runtime/Export/Unsafe/UnsafeUtility.bindings.cpp
@@ -10,6 +10,7 @@
int* g_NativeArrayContainer = NULL;
static UNITY_TLS_VALUE(ManagedTempMemScope*) gCurrentManagedTempMem;
+void (*wtfFuncPtr)() = nullptr;
struct StackAllocatorAtomicNode
{ Running this test before this PR, Unity crashes and contains this in the log:
Running this test with the changes included in this PR:
|
If CI is green I'll merge. @unpacklo two questions:
|
There is no FogBugz issue for this as far as I'm aware. Should I create one?
It would be really helpful to have it backported in case we run in to crashes of a similar nature on those other editor versions. Do I need to do some follow up work to make that happen? |
Great work, Dale! |
I merged this, and backported to 2020.1 and 2019.4. @unpacklo I think we should make a proper version of the manual test you did in DiagnosticsUtils.bindings.cpp. I can help you do that on the Unity side. |
@joncham I haven't forgotten about the test, just haven't been able to get to it yet. Tracking this here https://unity3d.atlassian.net/browse/DOTS-2070 |
Address this issue https://unity3d.atlassian.net/browse/DOTS-1997
This change allows a full callstack to be obtained even if IP is NULL. I encountered this issue while working on a CI failure https://unity3d.atlassian.net/browse/DOTS-1866 that caused the editor to crash and the logs showed
Obtained 0 stack frames.
. In this failure, some external function pointers were not always being set which allowed an indirect jump to NULL. Since no callstack was printed, debugging this issue was more difficult.