-
Notifications
You must be signed in to change notification settings - Fork 11.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SEGV when creating llvm::Function
& setting llvm::TargetTriple
#56224
Comments
llvm::Function
llvm::Function
& setting llvm::TargetTriple
The statements after the first return statement is the actual code in that file. I added the steps above that to easily debug the problem. This initially happened in the IR generation phase of my language |
Just got the source of the error for Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x000000000034ca1f qat`qat::IR::QatModule::QatModule(this=0x0000000000d70290, _name="nine.qat", _filename="�F�, ctx=0x0000000000d19bc8, _type=file, _visibility=<unavailable>) at qat_module.cpp:47:3
44 visibility(_visibility), active(nullptr) {
45 mod = new llvm::Module(_name, ctx);
46 mod->setCodeModel(llvm::CodeModel::Small);
-> 47 mod->setTargetTriple(LLVM_HOST_TRIPLE);
48 mod->setSourceFileName(_filename);
49 }
50
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x00000000002b5c32 qat`llvm::StringRef::StringRef(this=0x00007fffffffd288, Str="x86_64-unknown-linux-gnu") at StringRef.h:108:16
105
106 /// Construct a string ref from a cstring.
107 /*implicit*/ constexpr StringRef(const char *Str)
-> 108 : Data(Str), Length(Str ? strLen(Str) : 0) {}
109
110 /// Construct a string ref from a pointer and length.
111 /*implicit*/ constexpr StringRef(const char *data, size_t length)
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x00000000002b6524 qat`llvm::StringRef::strLen(Str="x86_64-unknown-linux-gnu") at StringRef.h:83:45
80 // Constexpr version of std::strlen.
81 static constexpr size_t strLen(const char *Str) {
82 #if __cplusplus > 201402L
-> 83 return std::char_traits<char>::length(Str);
84 #elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
85 (defined(_MSC_VER) && _MSC_VER >= 1916)
86 return __builtin_strlen(Str);
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x00000000002b6532 qat`llvm::StringRef::strLen(Str="ț�) at StringRef.h:83:7
80 // Constexpr version of std::strlen.
81 static constexpr size_t strLen(const char *Str) {
82 #if __cplusplus > 201402L
-> 83 return std::char_traits<char>::length(Str);
84 #elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
85 (defined(_MSC_VER) && _MSC_VER >= 1916)
86 return __builtin_strlen(Str);
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x00000000002b5c4d qat`llvm::StringRef::StringRef(this=0x00007fffffffd288, Str="x86_64-unknown-linux-gnu") at StringRef.h:108:29
105
106 /// Construct a string ref from a cstring.
107 /*implicit*/ constexpr StringRef(const char *Str)
-> 108 : Data(Str), Length(Str ? strLen(Str) : 0) {}
109
110 /// Construct a string ref from a pointer and length.
111 /*implicit*/ constexpr StringRef(const char *data, size_t length)
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x000000000034ca61 qat`qat::IR::QatModule::QatModule(this=0x0000000000d70290, _name=<unavailable>, _filename="�F�, ctx=0x0000000000d19bc8, _type=file, _visibility=<unavailable>) at qat_module.cpp:47:24
44 visibility(_visibility), active(nullptr) {
45 mod = new llvm::Module(_name, ctx);
46 mod->setCodeModel(llvm::CodeModel::Small);
-> 47 mod->setTargetTriple(LLVM_HOST_TRIPLE);
48 mod->setSourceFileName(_filename);
49 }
50
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = step in
frame #0: 0x000000000034cdac qat`llvm::Module::setTargetTriple(this=0x0000000000d74900, T=(Data = "x86_64-unknown-linux-gnu", Length = 24)) at Module.h:300:54
297 void setDataLayout(const DataLayout &Other);
298
299 /// Set the target triple.
-> 300 void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
301
302 /// Set the module-scope inline assembly blocks.
303 /// A trailing newline is added if the input doesn't have one.
(lldb) s
Process 46808 stopped
* thread #1, name = 'qat', stop reason = Nullptr with nonzero offset
frame #0: 0x00000000002af300 qat`__ubsan_on_report
qat`__ubsan_on_report:
-> 0x2af300 <+0>: retq
0x2af301: int3
0x2af302: int3
0x2af303: int3
(lldb) |
@EugeneZelenko
|
@AldrinMathew: You could try to ask questions on https://discourse.llvm.org |
Was LLVM compiled on the same machine your are experiencing the crash? Could you provide standalone reproducer ( |
Are you statically linking the binary or are you using shared libraries? This looks like the kind of bugs that happen when using a mismatch of shared libraries built at different version of the code, or with incompatible flags |
@danilaml The cause of the problem has been found a few hours ago. |
The following is the original error
And the code that causes the error is as follows
Seeing
StringMapImpl
, I initially thought that the error is related to StringRef. I separated function calls to individual statements and added debug prints to see the flow of execution upto the error. Turns out, it is caused by byllvm::Function::Create
when it is trying to see if thellvm::Value
exists already in the bucket.Later made a few changes to the code and added a step for setting Target triple of the module:
And guess what, the error happens at a different spot
I still think this might be caused by the
llvm::StringRef
and how I am initialising the value.The text was updated successfully, but these errors were encountered: