Title: [219233] trunk/Source/WTF
Revision
219233
Author
[email protected]
Date
2017-07-06 20:35:27 -0700 (Thu, 06 Jul 2017)

Log Message

Add extra insurance to prevent clang from making crash traces sad
https://bugs.webkit.org/show_bug.cgi?id=174231

Reviewed by Saam Barati.

This patch makes it slightly harder for Clang to coalesce our crash calls.
Additionally, it also makes Clang never tail call the WTFCrashWithInfo so
our stack trace should always be "reasonable".

* wtf/Assertions.h:
* wtf/Compiler.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (219232 => 219233)


--- trunk/Source/WTF/ChangeLog	2017-07-07 02:59:11 UTC (rev 219232)
+++ trunk/Source/WTF/ChangeLog	2017-07-07 03:35:27 UTC (rev 219233)
@@ -1,3 +1,17 @@
+2017-07-06  Keith Miller  <[email protected]>
+
+        Add extra insurance to prevent clang from making crash traces sad
+        https://bugs.webkit.org/show_bug.cgi?id=174231
+
+        Reviewed by Saam Barati.
+
+        This patch makes it slightly harder for Clang to coalesce our crash calls.
+        Additionally, it also makes Clang never tail call the WTFCrashWithInfo so
+        our stack trace should always be "reasonable".
+
+        * wtf/Assertions.h:
+        * wtf/Compiler.h:
+
 2017-07-06  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r219178.

Modified: trunk/Source/WTF/wtf/Assertions.h (219232 => 219233)


--- trunk/Source/WTF/wtf/Assertions.h	2017-07-07 02:59:11 UTC (rev 219232)
+++ trunk/Source/WTF/wtf/Assertions.h	2017-07-07 03:35:27 UTC (rev 219233)
@@ -471,14 +471,14 @@
 
 #ifdef __cplusplus
 
-// The combination of line, file, function, and counter should be a unique number per call to this crash. This forces the compiler to not coalesce calls to WTFCrashWithInfo.
+// The combination of line, file, function, and counter should be a unique number per call to this crash. This tricks the compiler into not coalescing calls to WTFCrashWithInfo.
 // The easiest way to fill these values per translation unit is to pass __LINE__, __FILE__, WTF_PRETTY_FUNCTION, and __COUNTER__.
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4);
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3);
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2);
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1);
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason);
-WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason);
+WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter);
 
 
 namespace WTF {
@@ -498,6 +498,7 @@
 #if COMPILER(CLANG) || COMPILER(MSVC)
 #define CRASH_WITH_SECURITY_IMPLICATION_AND_INFO(...) do { \
         WTF::isIntegralType(__VA_ARGS__); \
+        asm volatile("" ::: "memory"); \
         WTFCrashWithInfo(__LINE__, __FILE__, WTF_PRETTY_FUNCTION, __COUNTER__, ##__VA_ARGS__); \
     } while (false)
 #else

Modified: trunk/Source/WTF/wtf/Compiler.h (219232 => 219233)


--- trunk/Source/WTF/wtf/Compiler.h	2017-07-07 02:59:11 UTC (rev 219232)
+++ trunk/Source/WTF/wtf/Compiler.h	2017-07-07 03:35:27 UTC (rev 219233)
@@ -256,6 +256,16 @@
 #define NO_RETURN
 #endif
 
+/* NOT_TAIL_CALLED */
+
+#if !defined(NOT_TAIL_CALLED) && defined(__has_attribute) && __has_attribute(not_tail_called)
+#define NOT_TAIL_CALLED __attribute__((not_tail_called))
+#endif
+
+#if !defined(NOT_TAIL_CALLED)
+#define NOT_TAIL_CALLED
+#endif
+
 /* RETURNS_NONNULL */
 #if !defined(RETURNS_NONNULL) && COMPILER(GCC_OR_CLANG)
 #define RETURNS_NONNULL __attribute__((returns_nonnull))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to