mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Disable GC on c++ catch block w/ASAN
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
89ffa15d0b
commit
d0edfa8bf1
2 changed files with 26 additions and 0 deletions
|
|
@ -264,6 +264,16 @@ if (f.type == Type::B) { puts("failed in msvc."); }
|
|||
#define HAVE_BUILTIN_ATOMIC_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_CLANG)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define ASAN_ENABLED
|
||||
#endif
|
||||
#elif defined(COMPILER_GCC)
|
||||
#if defined(__SANITIZE_ADDRESS__)
|
||||
#define ASAN_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ SandBox::SandBoxResult SandBox::run(Value (*scriptRunner)(ExecutionState&, void*
|
|||
result.result = scriptRunner(state, data);
|
||||
} catch (const Value& err) {
|
||||
processCatch(err, result);
|
||||
#ifdef ASAN_ENABLED
|
||||
GC_enable();
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -123,6 +126,9 @@ SandBox::SandBoxResult SandBox::run(ExecutionState& parentState, Value (*runner)
|
|||
result.result = runner(state, data);
|
||||
} catch (const Value& err) {
|
||||
processCatch(err, result);
|
||||
#ifdef ASAN_ENABLED
|
||||
GC_enable();
|
||||
#endif
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -310,6 +316,11 @@ void SandBox::throwException(ExecutionState& state, const Value& exception)
|
|||
// We MUST save thrown exception Value.
|
||||
// because bdwgc cannot track `thrown value`(may turned off by GC_DONT_REGISTER_MAIN_STATIC_DATA)
|
||||
m_exception = exception;
|
||||
|
||||
// If ASAN is enabled, BDWGC cannot perform stack scanning properly in the catch block.
|
||||
#ifdef ASAN_ENABLED
|
||||
GC_disable();
|
||||
#endif
|
||||
throw exception;
|
||||
}
|
||||
|
||||
|
|
@ -322,6 +333,11 @@ void SandBox::rethrowPreviouslyCaughtException(ExecutionState& state, Value exce
|
|||
// We MUST save thrown exception Value.
|
||||
// because bdwgc cannot track `thrown value`(may turned off by GC_DONT_REGISTER_MAIN_STATIC_DATA)
|
||||
m_exception = exception;
|
||||
|
||||
// If ASAN is enabled, BDWGC cannot perform stack scanning properly in the catch block.
|
||||
#ifdef ASAN_ENABLED
|
||||
GC_disable();
|
||||
#endif
|
||||
throw exception;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue