Add logging to MachineStackMarker to try to diagnose crashes in the wild
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 20:02:22 +0000 (20:02 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 20:02:22 +0000 (20:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173427

Reviewed by Mark Lam.

This patch adds some logging to the MachineStackMarker constructor
to help figure out where we are seeing crashes. Since macOS does
not support os_log_info my hope is that if we set all the callee
save registers before making any calls in the C++ code we can
figure out which calls is the source of the crash. We also, set
all the caller save registers before returning in case some
weirdness is happening in the Heap constructor.

This logging should not matter from a performance perspective. We
only create MachineStackMarkers when we are creating a new VM,
which is already expensive.

* heap/MachineStackMarker.cpp:
(JSC::MachineThreads::MachineThreads):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218350 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/MachineStackMarker.cpp

index 5bd59ad..d96f80a 100644 (file)
@@ -1,3 +1,25 @@
+2017-06-15  Keith Miller  <keith_miller@apple.com>
+
+        Add logging to MachineStackMarker to try to diagnose crashes in the wild
+        https://bugs.webkit.org/show_bug.cgi?id=173427
+
+        Reviewed by Mark Lam.
+
+        This patch adds some logging to the MachineStackMarker constructor
+        to help figure out where we are seeing crashes. Since macOS does
+        not support os_log_info my hope is that if we set all the callee
+        save registers before making any calls in the C++ code we can
+        figure out which calls is the source of the crash. We also, set
+        all the caller save registers before returning in case some
+        weirdness is happening in the Heap constructor.
+
+        This logging should not matter from a performance perspective. We
+        only create MachineStackMarkers when we are creating a new VM,
+        which is already expensive.
+
+        * heap/MachineStackMarker.cpp:
+        (JSC::MachineThreads::MachineThreads):
+
 2017-06-15  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC] Implement Object.assign in C++
index 5b1ee90..6763ea3 100644 (file)
@@ -97,13 +97,49 @@ static ActiveMachineThreadsManager& activeMachineThreadsManager()
     });
     return *manager;
 }
-    
+
+#if CPU(X86_64) && OS(DARWIN)
+#define FILL_CALLEE_SAVES_FOR_CRASH_INFO(number)     \
+    asm volatile(                                    \
+        "movq $0xc0defefe000000" number ", %%rbx;" \
+        "movq $0xc0defefe000000" number ", %%r12;" \
+        "movq $0xc0defefe000000" number ", %%r13;" \
+        "movq $0xc0defefe000000" number ", %%r14;" \
+        "movq $0xc0defefe000000" number ", %%r15;" \
+        :                                            \
+        :                                            \
+        : "%rbx", "%r12", "%r13", "%r14", "%r15"     \
+    );
+
+#define FILL_CALLER_SAVES_FOR_CRASH_INFO(number)     \
+    asm volatile(                                    \
+        "movq $0xc0defefe000000" number ", %%rax;" \
+        "movq $0xc0defefe000000" number ", %%rdi;" \
+        "movq $0xc0defefe000000" number ", %%rsi;" \
+        "movq $0xc0defefe000000" number ", %%rdx;" \
+        "movq $0xc0defefe000000" number ", %%rcx;" \
+        "movq $0xc0defefe000000" number ", %%r8;"  \
+        "movq $0xc0defefe000000" number ", %%r9;"  \
+        "movq $0xc0defefe000000" number ", %%r10;" \
+        "movq $0xc0defefe000000" number ", %%r11;" \
+        :                                            \
+        :                                            \
+        : "%rax", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11" \
+    );
+#else
+#define FILL_CALLEE_SAVES_FOR_CRASH_INFO(number)
+#define FILL_CALLER_SAVES_FOR_CRASH_INFO(number)
+#endif
+
 MachineThreads::MachineThreads()
     : m_registeredThreads()
     , m_threadSpecificForMachineThreads(0)
 {
+    FILL_CALLEE_SAVES_FOR_CRASH_INFO("01");
     threadSpecificKeyCreate(&m_threadSpecificForMachineThreads, removeThread);
+    FILL_CALLEE_SAVES_FOR_CRASH_INFO("02");
     activeMachineThreadsManager().add(this);
+    FILL_CALLER_SAVES_FOR_CRASH_INFO("03");
 }
 
 MachineThreads::~MachineThreads()