summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2023-10-17 14:56:10 -0400
committerNat Goodspeed <nat@lindenlab.com>2023-10-17 14:56:10 -0400
commit651353560bfe23b6423ecf7690d86645a71c0cbc (patch)
tree67ae301d4bd27bbebe3002610b3292d326077051 /indra/llcommon
parent117f07e5a4b7882a44681c730dcc0628238cfec6 (diff)
SL-20476: Don't let the compiler know we intend to crash.
clang has gotten smart enough to recognize an inline attempt to store to address zero. Fool it by storing to an address passed as a parameter, and pass nullptr from a different source file.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llerror.cpp17
-rw-r--r--indra/llcommon/llerror.h10
2 files changed, 20 insertions, 7 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 02cb186275..05e719b494 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -1617,5 +1617,18 @@ bool debugLoggingEnabled(const std::string& tag)
return res;
}
-
-
+void crashdriver(void (*callback)(int*))
+{
+ // The LLERROR_CRASH macro used to have inline code of the form:
+ //int* make_me_crash = NULL;
+ //*make_me_crash = 0;
+
+ // But compilers are getting smart enough to recognize that, so we must
+ // assign to an address supplied by a separate source file. We could do
+ // the assignment here in crashdriver() -- but then BugSplat would group
+ // all LL_ERRS() crashes as the fault of this one function, instead of
+ // identifying the specific LL_ERRS() source line. So instead, do the
+ // assignment in a lambda in the caller's source. We just provide the
+ // nullptr target.
+ callback(nullptr);
+}
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index 020f05e8f5..624a5fb37a 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -383,11 +383,9 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
#define LL_NEWLINE '\n'
// Use this only in LL_ERRS or in a place that LL_ERRS may not be used
-#define LLERROR_CRASH \
-{ \
- int* make_me_crash = NULL;\
- *make_me_crash = 0; \
- exit(*make_me_crash); \
+#define LLERROR_CRASH \
+{ \
+ crashdriver([](int* ptr){ *ptr = 0; exit(*ptr); }); \
}
#define LL_ENDL \
@@ -466,5 +464,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
// Check at run-time whether logging is enabled, without generating output
bool debugLoggingEnabled(const std::string& tag);
+// used by LLERROR_CRASH
+void crashdriver(void (*)(int*));
#endif // LL_LLERROR_H