Navigation Menu

Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: don't blow up when an invalid FD is used
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Sep 22, 2012
1 parent b877db9 commit 39ca621
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/win/core.c
Expand Up @@ -24,6 +24,7 @@
#include <limits.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "uv.h"
Expand All @@ -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. */
Expand Down

2 comments on commit 39ca621

@saghul
Copy link
Contributor

@saghul saghul commented on 39ca621 Oct 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails to compile on MinGW when doing make test:

$ make test
gcc -Iinclude -Iinclude/uv-private -Iinclude -Iinclude/uv-private -g --std=gnu89
 -D_WIN32_WINNT=0x0600 -Isrc/ares/config_win32 -D_GNU_SOURCE  -o test/run-tests
test/run-tests.c \
                test/runner.c test/runner-win.c test/blackhole-server.c test/ech
o-server.c test/test-*.c uv.a -lws2_32 -lpsapi -liphlpapi -lm
uv.a(core.o): In function `uv_init':
c:\Users\saghul\src\libuv/src/win/core.c:58: undefined reference to `_set_invali
d_parameter_handler'
collect2: ld devolvi¾ el estado de salida 1
make: *** [test/run-tests.exe] Error 1

@saghul
Copy link
Contributor

@saghul saghul commented on 39ca621 Oct 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix, as discussed on IRC: saghul/libuv@046f788

Please sign in to comment.