Skip to content

Exception issues on OSX #48

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

Closed
dbertrand402 opened this issue Jan 6, 2016 · 5 comments
Closed

Exception issues on OSX #48

dbertrand402 opened this issue Jan 6, 2016 · 5 comments
Assignees

Comments

@dbertrand402
Copy link

CPPRest compiled on OSX exhibits a problem catching exceptions properly :

try
  {
    json::value::parse("some badly formatted JSON");
  }
  catch( const json::json_exception& e )
  {
    cout << "json::json_exception caught" << endl;
  }
  catch( const std::exception& e )
  {
    cout << "std::exception caught" << endl;
  }

Following code displays "std::exception caught" on OSX. This really should display "json::json_exception caught", instead. I suspect this is caused by known Apple GCC issue when shared libraries are not built using RTTI. See following StackOverflow article :

Polymorphically catching an exception in a -fno-rtti shared library on Mac OS X

(CPPRest 2.6.0, OSX Yosemite, XCode 6.4)

CPPRest issue repro.zip

@ras0219-msft ras0219-msft self-assigned this Jan 14, 2016
@ras0219-msft
Copy link
Contributor

I'm not seeing this issue with the default settings:

$ c++ CPPRest\ issue\ repro.cpp -I casablanca/Release/include -L casablanca/build.relstatic/Binaries -lcpprest -I /usr/local/include -std=c++11 -lssl -lcrypto -L/usr/local/lib -lboost_system
In file included from CPPRest issue repro.cpp:3:
In file included from casablanca/Release/include/cpprest/json.h:36:
In file included from casablanca/Release/include/cpprest/details/basic_types.h:41:
casablanca/Release/include/cpprest/details/SafeInt3.hpp:125:34: warning: unknown warning group '-Wunused-local-typedef', ignored [-Wunknown-pragmas]
#pragma clang diagnostic ignored "-Wunused-local-typedef"
                                 ^
1 warning generated.
$ ./a.out
json::json_exception caught
$

This is with the latest development version and the compiler version:

$ c++ --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

On OSX we only support clang, are you trying to build with gcc?

@dbertrand402
Copy link
Author

I'm using the Apple LLVM 6.1 compiler. The only difference I can see is that I'm using XCode IDE while you are using the Terminal.

$ c++ --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

@ras0219-msft
Copy link
Contributor

Could you try the command line approach and see if you're getting the same behavior that I see? If so, then we can narrow it down to XCode being the problem.

@dbertrand402
Copy link
Author

Found out issue is caused by "Symbols Hidden By Default" being set to YES in Release. Setting it to NO solves the problem.

@ras0219-msft
Copy link
Contributor

Thanks for posting the resolution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants