diff --git a/src/win/core.c b/src/win/core.c index 79fb655c..5b47c202 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "uv.h" @@ -40,10 +41,21 @@ static uv_once_t uv_init_guard_ = UV_ONCE_INIT; static uv_once_t uv_default_loop_init_guard_ = UV_ONCE_INIT; +static void uv__crt_invalid_parameter_handler(const wchar_t* expression, + const wchar_t* function, const wchar_t * file, unsigned int line, + uintptr_t reserved) { + /* No-op. */ +} + + static void uv_init(void) { /* Tell Windows that we will handle critical errors. */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); + SEM_NOOPENFILEERRORBOX); + + /* Tell the CRT to not exit the application when an invalid parameter is */ + /* passed. The main issue is that invalid FDs will trigger this behavior. */ + _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler); /* Fetch winapi function pointers. This must be done first because other */ /* intialization code might need these function pointers to be loaded. */