[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash occurs when catching std::exception in Objective-C++ code comp

From: Lobron, David
Subject: Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2
Date: Thu, 16 Nov 2017 20:50:24 +0000

Hi David and gnustep,

This test case works perfectly for me on FreeBSD, where clang defaults to -fobjc-runtime=gnustep.  It segfaults if I add -fobjc-runtime=gcc.  This is entirely expected, because the GCC ABI for exceptions is makes it impossible to correctly interop with C++ (I spent a few weeks trying and it always fails for at least some of the corner cases).  If you specify -fobjc-runtime=gnustep-1.8, then it will work correctly.

I updated my gnustep-make (version 2.6.0) to include -fobjc-runtime=gnustep-1.8 in ADDITIONAL_FLAGS, with the following change to common.make:

> # Specify the gnustep-1.8 runtime so we pick up the correct exception personalities
> # in ObjCC.
> ADDITIONAL_FLAGS += -fobjc-runtime=gnustep-1.8 

This works as expected, as this sample compilation line that has the -fobjc-runtime=gnustep-1.8 flag:

/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++ ResourceAdditions.mm -c \
      -MMD -MP -idirafter /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -fobjc-runtime=gnustep-1.8 -mfpmath=sse -msse2 -fno-strict-aliasing -Wall -Werror -Wno-multichar -DHAVE_CONFIG_H -D_GNU_SOURCE -m64 -march=opteron -mno-3dnow -ggdb -O2 -Wall -fPIC -fPIC -fgnu-runtime -std=c++11 -fconstant-string-class=NSConstantString -I ../common/include -I. -I/home/dlobron/GNUstep/Library/Headers -I/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Headers -I/home/dlobron/build/clangport/akamai/common/GNUstep/System/Library/Headers

However, I'm still getting the same result: C++ exception objects are nil when caught in Objective-C++ code (.mm files).  As I mentioned, I'm using libobjc2 and building with clang.  This error does not occur when I build with gcc, nor with clang on a Mac - only clang on Linux.

Is it possible that some key part of my compilation is missing -fobjc-runtime=gnustep-1.8?  It appears everywhere I can think to look, and ADDITIONAL_FLAGS does seem like the right place to put it.  Please let me know if there is something else I might check.  I did notice that the flag "-fgnu-runtime" appears in my compilation line - could that value be incorrect?

Thank you,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]