[llvm-bugs] [Bug 51433] New: crash for "x86_64-w64-windows-gnu" because of architecture triple mismatch - solution proposition

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 10 10:42:00 PDT 2021


            Bug ID: 51433
           Summary: crash for  "x86_64-w64-windows-gnu" because of
                    architecture triple mismatch - solution proposition
           Product: lldb
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: rolchg at gmail.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

The problem concerns the 64bit lldb (12.0.01 and 14.0.0) debugger compiled for
The debugger crashes if a variable of type class method pointer is examined.
Debugging of the lldb shown the problem is a result of the architecture
"triple" mismatch, and a difference in the implementation of class method
pointers between "msvc" and "gnu".
The triplet lldb  for debugged exe file obtains the  by method
and sets it to "x86_64-pc-windows". Finally the triplet is transformed to
""x86_64-pc-windows.msvc"  by Triple::normalize at the clang side.

It seems to be reasonable to resolve the problem at its origin, by replacing
the wrong hard coded triple value, in "ObjectFilePECOFF::
GetModuleSpecifications" to the proper one, by using some additional criteria.

Here is the patch:

diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 9eb1c25d2403..61550682a019 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Object/COFFImportFile.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Host.h"

 #define IMAGE_DOS_SIGNATURE 0x5A4D    // MZ
 #define IMAGE_NT_SIGNATURE 0x00004550 // PE00
@@ -163,7 +164,10 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(

   switch (COFFObj->getMachine()) {
   case MachineAmd64:
-    spec.SetTriple("x86_64-pc-windows");
+       if(llvm::sys::getProcessTriple()=="x86_64-w64-windows-gnu")
+               spec.SetTriple("x86_64-w64-windows-gnu");
+       else
+               spec.SetTriple("x86_64-pc-windows");
   case MachineX86:

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210810/f2c63fc7/attachment.html>

More information about the llvm-bugs mailing list