[llvm-dev] Segmentation fault observed when a std::exception is thrown in a C++ program compiled with clang/llvm-5.0.0 as Objective-C++
Lobron, David via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 8 12:20:27 PDT 2017
Hello llvm-dev,
I am working to port a large compilation job from gcc to clang. The code compiles and runs correctly with clang on OSX/Darwin. However, I'm observing failures on Linux when I compile with clang/llvm-5.0.0 (the latest svn tree, checked out and built from scratch today), with libobjc2 as the Objective-C runtime. The proximate cause of the crashes is a NULL std::exception object. This is evident when I examine the stack from my minimal reproducer in gdb:
exceptionObject = 0x0
A more complicated program, which uses a custom C++ exception class derived from std::exception, also shows this symptom (here, the variable "e" is of the derived exception type):
e = @0x0: <error reading variable>
The minimal reproducing test program is entirely C++. The crash only occurs when I compiled it as a .mm (Objective-C++) program. When I compile it as plain C++ (.cc), the problem goes away and the program runs correctly.
I've attached the reproducing program (as .cc and .mm files that are otherwise identical), and compilation scripts C++ and Objective-C++ (to reproduce, just adjust the paths in the scripts). Any help here would be greatly appreciated.
Thank you,
David
Demonstration that the .cc and .mm programs are the same:
MD5 (testMin.cc) = 7a8ea3886e3e0550a96f8e1d235b7fae
MD5 (testMin.mm) = 7a8ea3886e3e0550a96f8e1d235b7fae
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmdCpp.sh
Type: application/octet-stream
Size: 359 bytes
Desc: cmdCpp.sh
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170908/76577130/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmdOjbcc.sh
Type: application/octet-stream
Size: 889 bytes
Desc: cmdOjbcc.sh
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170908/76577130/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testMin.cc
Type: application/octet-stream
Size: 167 bytes
Desc: testMin.cc
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170908/76577130/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testMin.mm
Type: application/octet-stream
Size: 167 bytes
Desc: testMin.mm
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170908/76577130/attachment-0003.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001.txt
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170908/76577130/attachment.txt>
More information about the llvm-dev
mailing list