Skip to content

Commit

Permalink
Export exception classes with default visibility
Browse files Browse the repository at this point in the history
Summary:
This fixes a crash caused by a `JSError` exception not being successfully caught in a different dynamic library from where it was thrown. Since the libraries were compiled with hidden symbols and loaded with `RTLD_LOCAL`, the exception typeinfo becomes unique to each module.

Reading on this subject:
https://gcc.gnu.org/wiki/Visibility
https://stackoverflow.com/questions/14268736/symbol-visibility-exceptions-runtime-error

Reviewed By: mhorowitz

Differential Revision: D19343161

fbshipit-source-id: 4eb3bc2576bbcca2c3aef4f52b5a27dfde214c6a
  • Loading branch information
appden authored and facebook-github-bot committed Jan 19, 2020
1 parent 475df06 commit 84adc85
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ReactCommon/jsi/jsi/jsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ class Scope {
};

/// Base class for jsi exceptions
class JSIException : public std::exception {
class JSI_EXPORT JSIException : public std::exception {
protected:
JSIException(){};
JSIException(std::string what) : what_(std::move(what)){};
Expand All @@ -1207,15 +1207,15 @@ class JSIException : public std::exception {

/// This exception will be thrown by API functions on errors not related to
/// JavaScript execution.
class JSINativeException : public JSIException {
class JSI_EXPORT JSINativeException : public JSIException {
public:
JSINativeException(std::string what) : JSIException(std::move(what)) {}
};

/// This exception will be thrown by API functions whenever a JS
/// operation causes an exception as described by the spec, or as
/// otherwise described.
class JSError : public JSIException {
class JSI_EXPORT JSError : public JSIException {
public:
/// Creates a JSError referring to provided \c value
JSError(Runtime& r, Value&& value);
Expand Down

0 comments on commit 84adc85

Please sign in to comment.