discuss-gnustep
[Top][All Lists]
Advanced

[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: Tue, 28 Nov 2017 21:38:06 +0000

Hey All-

I've been continuing to dig into the phenomenon of code crashing when catching 
a C++ exception in a .mm file.  I'm finding that even though my test passes 
when it's included in the libobjc2 test bundle, it fails when I compile it from 
the command line.  I narrowed down the compilation command, and found that the 
seg fault stops happening if I remove -fgnu-runtime from the compile command 
(I've copied the commands and the program below).

Should I not be compiling with -fgnu-runtime when I'm using the libobjc2 
runtime?  

--David

Compilation command that results in crash:
/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++ 
test.mm -c \
      -fPIC -Wall -Wall -Werror -fobjc-runtime=gnustep-1.8 -DHAVE_CONFIG_H 
-D_GNU_SOURCE -fgnu-runtime  -I .. -I ../../common/include \
           -o test.mm.o
/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++   -o 
test \
    ./test.mm.o \
    -L../../common/lib -L..  -lobjc

Command with no crash (only change is remove -fgnu-runtime):
/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++ 
test.mm -c \
      -fPIC -Wall -Wall -Werror -fobjc-runtime=gnustep-1.8 -DHAVE_CONFIG_H 
-D_GNU_SOURCE  -I .. -I ../../common/include \
           -o test.mm.o
/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang++   -o 
test \
    ./test.mm.o \
    -L../../common/lib -L..  -lobjc 

Program (C++ code in a .mm file):

$ cat test.mm
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  try {
    throw exception();
  } catch (exception &e) {
  }

  return 0;
}


reply via email to

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