================
@@ -107,7 +107,15 @@ DecodedThread::CreateNewTraceItem(lldb::TraceItemKind 
kind) {
     (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
     (*m_last_nanoseconds)->second.items_count++;
-  return m_item_data.back();
+
+  TraceItemStorage &data = m_item_data.back();
+
+  // If creating an error item, then properly initialize TraceItemStorage's
+  // non-trivially-constructible union member `error`.
+  if (kind == lldb::eTraceItemKindError)
+    new (&data.error) std::string();
----------------
nmosier wrote:

I don't think so (I tried it, and the crash came back). The problem is that 
before line 116, `data.error` is uninitialized. Thus `data.error = {}` 
implicitly invokes the destructor of `data.error` on uninitialized memory 
before constructing a new std::string, causing a crash. 

https://github.com/llvm/llvm-project/pull/77252
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to