-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash with filedescriptor > 1024 #527
Comments
Not good indeed, I can see in CMakeLists.txt that the default eventloop based on select is chosen when a test trying to compile with poll fails:
Could you share your config.h perhaps to see why it was not included. |
And I agree that in case of a compile for windows and for some reason the select eventloop was choses, fds > 1024 should soft fail... |
Here is my config.h file. #ifndef CONFIG_H #define PACKAGE "getdns" #define PACKAGE_STRING "getdns 1.7.2" #define HAVE_ASSERT_H 1 #define HAVE_FCNTL_H 1 #define HAVE_SIGNAL_H 1 /* #undef HAVE_ENDIAN_H / #define HAVE_WINDOWS_H 1 #define HAVE_SSL 1 #define HAVE_OPENSSL_SSL_H 1 #define HAVE_DSA_SIG_SET0 1 #define HAVE_RSA_SET0_KEY 1 #define HAVE_EVP_MD5 1 /* #undef HAVE_EVP_DSS1 */ #define HAVE_EVP_MD_CTX_NEW 1 #define HAVE_HMAC_CTX_NEW 1 /* #undef HAVE_NETTLE_GET_SECP_256R1 / #define HAVE_TLS_CLIENT_METHOD 1 #define HAVE_OPENSSL_VERSION_NUM 1 #define HAVE_SSL_CTX_DANE_ENABLE 1 #define HAVE_OPENSSL_INIT_CRYPTO 1 /* #undef HAVE_OSSL_PARAM_BLD_NEW */ #define HAVE_SSL_DANE_ENABLE 1 #define HAVE_PTHREAD 1 /* #undef RUNSTATEDIR */ #define DNSSEC_ROADBLOCK_AVOIDANCE 1 /* #undef HAVE_DECL_GETENTROPY / /* #undef HAVE_DECL_TCP_FASTOPEN / #if defined(HAVE_DECL_INET_PTON) || defined(HAVE_WIN_DECL_INET_PTON) /* #undef HAVE_FCNTL / /* #undef HAVE_SIGSET_T */ /* #undef HAVE_BSD_STDLIB_H / /* #undef HAVE_DECL_STRLCPY / /* #undef HAVE_STRLCPY / /* #undef HAVE_LIBUNBOUND / /* #undef HAVE_LIBIDN / /* #undef HAVE_NETTLE / /* #undef HAVE_EVENT2_EVENT_H / #define DEFAULT_EVENTLOOP "select_eventloop" /* #undef STRPTIME_WORKS */ /* #undef FD_SETSIZE */ #define REQ_DEBUG 1 #define USE_SHA1 1 /* #undef USE_OSX_TCP_FASTOPEN */ /* #undef HAVE_DECL_TCP_USER_TIMEOUT */ /* #undef HAVE_NEW_UV_TIMER_CB */ #define HAVE_TARGET_ENDIANNESS #define HAVE___FUNC__ 1 #ifdef HAVE___FUNC__ #ifdef GETDNS_ON_WINDOWS
ifndef FD_SETSIZEdefine FD_SETSIZE 1024endif/* the version of the windows API enabled */ ifndef WINVERdefine WINVER 0x0600 // 0x0502endififndef _WIN32_WINNTdefine _WIN32_WINNT 0x0600 // 0x0502endififdef HAVE_WS2TCPIP_Hinclude <ws2tcpip.h>endififdef _MSC_VERif _MSC_VER >= 1800define PRIsz "zu"elsedefine PRIsz "Iu"endifinclude <BaseTsd.h>typedef SSIZE_T ssize_t; elsedefine PRIsz "Iu"endififdef HAVE_WINSOCK2_Hinclude <winsock2.h>endif/* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ ifdef HAVE_WINSOCK2_Hdefine FD_SET_T (u_int)elsedefine FD_SET_Tendif/* Windows wants us to use _strdup instead of strdup */ ifndef strdupdefine strdup _strdupendif/* Windows doesn't have strcasecmp and strncasecmp. */ define strcasecmp _stricmpdefine strncasecmp _strnicmp#else define PRIsz "zu"#endif #ifdef HAVE_STDINT_H #ifdef HAVE_STDIO_H #ifdef HAVE_UNISTD_H #ifdef HAVE_ASSERT_H #ifdef HAVE_STRING_H #ifdef __cplusplus #if STDC_HEADERS #ifdef HAVE_BSD_STDLIB_H #ifdef HAVE_BSD_STRING_H #if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY || !defined(strlcpy) #ifdef USE_WINSOCK ifndef _CUSTOM_VSNPRINTFdefine _CUSTOM_VSNPRINTFstatic inline int _gldns_custom_vsnprintf(char *str, size_t size, const char *format, va_list ap) define vsnprintf _gldns_custom_vsnprintfendif#endif #ifdef __cplusplus /** Use on-board gldns */ define GLDNS_BUILD_CONFIG_HAVE_SSL 1#endif #ifdef HAVE_STDARG_H #include <errno.h> #ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_STAT_H #ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_TCP_H #ifdef HAVE_ARPA_INET_H #ifdef HAVE_SIGNAL_H #ifdef HAVE_SYS_TYPES_H #ifdef HAVE_INTTYPES_H #ifdef HAVE_LIMITS_H #ifdef HAVE_SYS_LIMITS_H #ifdef PATH_MAX #ifndef PRIu64 #ifdef HAVE_ATTR_FORMAT define ATTR_FORMAT(archetype, string_index, first_to_check) \
#else /* !HAVE_ATTR_FORMAT */ define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */#endif /* !HAVE_ATTR_FORMAT */ #if defined(DOXYGEN) define ATTR_UNUSED(x) x#elif defined(__cplusplus) define ATTR_UNUSED(x)#elif defined(GNUC) define ATTR_UNUSED(x) x attribute((unused))#else /* !HAVE_ATTR_UNUSED */ define ATTR_UNUSED(x) x#endif /* !HAVE_ATTR_UNUSED */ #ifdef TIME_WITH_SYS_TIME include <sys/time.h>include <time.h>#else ifdef HAVE_SYS_TIME_Hinclude <sys/time.h>elseinclude <time.h>endif#endif #ifdef __cplusplus #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS) #if !defined(HAVE_SIGSET_T) && defined(HAVE__SIGSET_T) define sigemptyset(pset) (*(pset) = 0)#endif define sigfillset(pset) (*(pset) = (sigset_t)-1)#endif define sigaddset(pset, num) (*(pset) |= (1L<<(num)))#endif #ifdef HAVE_LIBUNBOUND include <unbound.h>ifdef HAVE_UNBOUND_EVENT_Hinclude <unbound-event.h>elseifdef HAVE_UNBOUND_EVENT_APIifndef _UB_EVENT_PRIMITIVESdefine _UB_EVENT_PRIMITIVESstruct ub_event_base; endifendifendif#endif #ifndef HAVE_DECL_INET_PTON #ifndef HAVE_DECL_INET_NTOP #ifndef HAVE_DECL_MKSTEMP #ifndef HAVE_GETTIMEOFDAY #ifdef __cplusplus #endif /* CONFIG_H */` |
This is a significant problem for windows adoption because currently vcpkg builds version 1.7.0 with a hardcoded Not sure how windows tends to handle file descriptors, but in my case, all file descriptors returned by getdns_return_t
_getdns_submit_stub_request(getdns_network_req *netreq, uint64_t *now_ms)
{
int fd = -1;
getdns_dns_req *dnsreq;
getdns_context *context;
DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNC__,
(void*)netreq, netreq->request_type);
dnsreq = netreq->owner;
context = dnsreq->context;
/* This does a best effort to get a initial fd.
* All other set up is done async*/
fd = upstream_find_for_netreq(netreq); The crash, or in my instance infinite loop comes from the fact the scheduling function fails and doesn't set I think what are the timeout callbacks. So when the handlers run in the future, it turns into an infinite loop. static getdns_return_t
select_eventloop_schedule(getdns_eventloop *loop,
int fd, uint64_t timeout, getdns_eventloop_event *event)
{
_getdns_select_eventloop *select_loop = (_getdns_select_eventloop *)loop;
size_t i;
DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p, FD_SETSIZE: %d)\n"
, __FUNC__, (void *)loop, fd, timeout, (void *)event, FD_SETSIZE);
if (!loop || !event)
return GETDNS_RETURN_INVALID_PARAMETER;
if (fd >= (int)FD_SETSIZE) {
DEBUG_SCHED( "ERROR: fd %d >= FD_SETSIZE: %d!\n"
, fd, FD_SETSIZE);
return GETDNS_RETURN_GENERIC_ERROR;
} I'd suspect there's a potential bug fix to make sure the |
It looks like there needs to be a bit of a rewrite such that |
Hi,
I am using the synchonous mode.
I have been using getdns for over a year on Linux but know I am porting my code to Windows and I am getting an error when the file descriptor is higher than 1024. This happens after a few successful requests.
I am aware of this ticket #222, which says that poll is now the default for the event loop but I can tell that this is not the case; using gdb I was able to see the code going in functions part of the select_eventloop.c and use the select mechanism.
I tested with 1.7.2 and got the same behavior.
What is the solution?
PS. The code should be cleanly failing but it not the case; the request is still attempted but never returns. The result is a thread that consumes 100% of the CPU. Not good!
PPS I am cross-compiling with mingw32-w64
The text was updated successfully, but these errors were encountered: