File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,19 @@ static void Abort(const FunctionCallbackInfo<Value>& args) {
7070 ABORT ();
7171}
7272
73- // For internal testing only, not exposed to userland.
74- static void CauseSegfault (const FunctionCallbackInfo<Value>& args) {
73+ // For internal testing only, not exposed to userland. If possible, disable
74+ // optimizations since we are technically relying on an undefined behavior that
75+ // modern compilers like to abuse.
76+ #ifdef __has_cpp_attribute
77+ #if __has_cpp_attribute(clang::optnone)
78+ [[clang::optnone]]
79+ #endif
80+ #if __has_cpp_attribute(gnu::optimize)
81+ [[gnu::optimize(0 )]]
82+ #endif
83+ #endif
84+ static void
85+ CauseSegfault (const FunctionCallbackInfo<Value>& args) {
7586 // This should crash hard all platforms.
7687 volatile void ** d = static_cast <volatile void **>(nullptr );
7788 *d = nullptr ;
You can’t perform that action at this time.
0 commit comments