Skip to content

Commit 0b1ca4a

Browse files
evanlucasFishrock123
authored andcommitted
src: Add ABORT macro
Windows 8+ compiled in Release mode exits with code 0xC0000409 when abort() is called. This prevents us from being able to reliably verify an abort exit code (3) on windows. PR-URL: #2776 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
1 parent 5905b14 commit 0b1ca4a

11 files changed

+28
-21
lines changed

src/cares_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
10671067
break;
10681068
default:
10691069
CHECK(0 && "bad address family");
1070-
abort();
1070+
ABORT();
10711071
}
10721072

10731073
GetAddrInfoReqWrap* req_wrap = new GetAddrInfoReqWrap(env, req_wrap_obj);
@@ -1193,7 +1193,7 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
11931193
break;
11941194
default:
11951195
CHECK(0 && "Bad address family.");
1196-
abort();
1196+
ABORT();
11971197
}
11981198

11991199
if (err)

src/fs_event_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
146146
event_string = env->change_string();
147147
} else {
148148
CHECK(0 && "bad fs events flag");
149-
abort();
149+
ABORT();
150150
}
151151

152152
Local<Value> argv[] = {

src/node.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
918918

919919
if (!tick_callback_function->IsFunction()) {
920920
fprintf(stderr, "process._tickDomainCallback assigned to non-function\n");
921-
abort();
921+
ABORT();
922922
}
923923

924924
process_object->Set(env->tick_callback_string(), tick_callback_function);
@@ -1526,7 +1526,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
15261526

15271527

15281528
static void Abort(const FunctionCallbackInfo<Value>& args) {
1529-
abort();
1529+
ABORT();
15301530
}
15311531

15321532

@@ -2146,14 +2146,14 @@ static void OnFatalError(const char* location, const char* message) {
21462146
fprintf(stderr, "FATAL ERROR: %s\n", message);
21472147
}
21482148
fflush(stderr);
2149-
abort();
2149+
ABORT();
21502150
}
21512151

21522152

21532153
NO_RETURN void FatalError(const char* location, const char* message) {
21542154
OnFatalError(location, message);
21552155
// to suppress compiler warning
2156-
abort();
2156+
ABORT();
21572157
}
21582158

21592159

@@ -3555,9 +3555,9 @@ inline void PlatformInit() {
35553555
// Anything but EBADF means something is seriously wrong. We don't
35563556
// have to special-case EINTR, fstat() is not interruptible.
35573557
if (errno != EBADF)
3558-
abort();
3558+
ABORT();
35593559
if (fd != open("/dev/null", O_RDWR))
3560-
abort();
3560+
ABORT();
35613561
}
35623562

35633563
CHECK_EQ(err, 0);

src/node_crypto.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void crypto_lock_init(void) {
182182

183183
for (i = 0; i < n; i++)
184184
if (uv_mutex_init(locks + i))
185-
abort();
185+
ABORT();
186186
}
187187

188188

@@ -3466,7 +3466,7 @@ void SignBase::CheckThrow(SignBase::Error error) {
34663466
case kSignPublicKey:
34673467
return env()->ThrowError("PEM_read_bio_PUBKEY failed");
34683468
default:
3469-
abort();
3469+
ABORT();
34703470
}
34713471
}
34723472

src/node_crypto_bio.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) {
172172
break;
173173
case BIO_C_SET_BUF_MEM:
174174
CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
175-
abort();
175+
ABORT();
176176
break;
177177
case BIO_C_GET_BUF_MEM_PTR:
178178
CHECK(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");

src/spawn_sync.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
485485
r = uv_run(uv_loop_, UV_RUN_DEFAULT);
486486
if (r < 0)
487487
// We can't handle uv_run failure.
488-
abort();
488+
ABORT();
489489

490490
// If we get here the process should have exited.
491491
CHECK_GE(exit_status_, 0);
@@ -508,7 +508,7 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
508508
// callbacks called.
509509
int r = uv_run(uv_loop_, UV_RUN_DEFAULT);
510510
if (r < 0)
511-
abort();
511+
ABORT();
512512

513513
CHECK_EQ(uv_loop_close(uv_loop_), 0);
514514
delete uv_loop_;

src/stream_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static Local<Object> AcceptHandle(Environment* env, StreamWrap* parent) {
179179
handle = wrap->UVHandle();
180180

181181
if (uv_accept(parent->stream(), reinterpret_cast<uv_stream_t*>(handle)))
182-
abort();
182+
ABORT();
183183

184184
return scope.Escape(wrap_obj);
185185
}

src/tls_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void TLSWrap::InitSSL() {
152152
SSL_set_connect_state(ssl_);
153153
} else {
154154
// Unexpected
155-
abort();
155+
ABORT();
156156
}
157157

158158
// Initialize ring for queud clear data

src/tty_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
7272
case UV_NAMED_PIPE: type = "PIPE"; break;
7373
case UV_UNKNOWN_HANDLE: type = "UNKNOWN"; break;
7474
default:
75-
abort();
75+
ABORT();
7676
}
7777

7878
args.GetReturnValue().Set(OneByteString(env->isolate(), type));

src/udp_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
166166
break;
167167
default:
168168
CHECK(0 && "unexpected address family");
169-
abort();
169+
ABORT();
170170
}
171171

172172
if (err == 0) {
@@ -278,7 +278,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
278278
break;
279279
default:
280280
CHECK(0 && "unexpected address family");
281-
abort();
281+
ABORT();
282282
}
283283

284284
if (err == 0) {

src/util.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ namespace node {
1818
TypeName(const TypeName&) = delete; \
1919
TypeName(TypeName&&) = delete
2020

21+
// Windows 8+ does not like abort() in Release mode
22+
#ifdef _WIN32
23+
#define ABORT() raise(SIGABRT)
24+
#else
25+
#define ABORT() abort()
26+
#endif
27+
2128
#if defined(NDEBUG)
2229
# define ASSERT(expression)
2330
# define CHECK(expression) \
2431
do { \
25-
if (!(expression)) abort(); \
32+
if (!(expression)) ABORT(); \
2633
} while (0)
2734
#else
2835
# define ASSERT(expression) assert(expression)
@@ -43,7 +50,7 @@ namespace node {
4350
#define CHECK_LT(a, b) CHECK((a) < (b))
4451
#define CHECK_NE(a, b) CHECK((a) != (b))
4552

46-
#define UNREACHABLE() abort()
53+
#define UNREACHABLE() ABORT()
4754

4855
// TAILQ-style intrusive list node.
4956
template <typename T>

0 commit comments

Comments
 (0)