Skip to content

Commit 7a1d5a4

Browse files
nodejs-github-botRafaelGSS
authored andcommitted
deps: update c-ares to v1.32.2
PR-URL: #53865 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 893c864 commit 7a1d5a4

17 files changed

+757
-281
lines changed

deps/cares/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles)
1212
INCLUDE (CheckStructHasMember)
1313
INCLUDE (CheckLibraryExists)
1414

15-
PROJECT (c-ares LANGUAGES C VERSION "1.32.1" )
15+
PROJECT (c-ares LANGUAGES C VERSION "1.32.2" )
1616

1717
# Set this version before release
1818
SET (CARES_VERSION "${PROJECT_VERSION}")
@@ -30,7 +30,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w
3030
# For example, a version of 4:0:2 would generate output such as:
3131
# libname.so -> libname.so.2
3232
# libname.so.2 -> libname.so.2.2.0
33-
SET (CARES_LIB_VERSIONINFO "19:1:17")
33+
SET (CARES_LIB_VERSIONINFO "19:2:17")
3434

3535

3636
OPTION (CARES_STATIC "Build as a static library" OFF)

deps/cares/RELEASE-NOTES.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## c-ares version 1.32.2 - July 15 2024
2+
3+
This is a bugfix release.
4+
5+
Bugfixes:
6+
7+
* Windows: rework EventThread AFD code for better stability.
8+
[PR #811](https://github.com/c-ares/c-ares/pull/811)
9+
* Windows: If an IP address was detected to have changed, it could lead to a
10+
crash due to a bad pointer. Regression introduced in 1.31.0.
11+
[59e3a1f4](https://github.com/c-ares/c-ares/commit/59e3a1f4)
12+
* Windows: use `QueryPerformanceCounters()` instead of `GetTickCount64()` for
13+
better time accuracy (~15ms -> ~1us).
14+
* Windows 32bit config change callback needs to be tagged as `stdcall` otherwise
15+
could result in a crash.
16+
[5c2bab35](https://github.com/c-ares/c-ares/commit/5c2bab35)
17+
* Tests that need accurate timing should not depend on internal symbols as there
18+
are C++ equivalents in `std::chrono`.
19+
[PR #809](https://github.com/c-ares/c-ares/pull/809)
20+
* Kqueue (MacOS, \*BSD): If the open socket count exceeded 8 (unlikely), it
21+
would try to allocate a new buffer that was too small.
22+
[5aad7981](https://github.com/c-ares/c-ares/commit/5aad7981)
23+
24+
125
## c-ares version 1.32.1 - July 7 2024
226

327
This is a bugfix release.

deps/cares/aminclude_static.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# aminclude_static.am generated automatically by Autoconf
3-
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
3+
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024
44

55

66
# Code coverage

deps/cares/configure

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.72 for c-ares 1.32.1.
3+
# Generated by GNU Autoconf 2.72 for c-ares 1.32.2.
44
#
55
# Report bugs to <c-ares mailing list: http://lists.haxx.se/listinfo/c-ares>.
66
#
@@ -614,8 +614,8 @@ MAKEFLAGS=
614614
# Identity of this package.
615615
PACKAGE_NAME='c-ares'
616616
PACKAGE_TARNAME='c-ares'
617-
PACKAGE_VERSION='1.32.1'
618-
PACKAGE_STRING='c-ares 1.32.1'
617+
PACKAGE_VERSION='1.32.2'
618+
PACKAGE_STRING='c-ares 1.32.2'
619619
PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares'
620620
PACKAGE_URL=''
621621

@@ -1415,7 +1415,7 @@ if test "$ac_init_help" = "long"; then
14151415
# Omit some internal or obsolete options to make the list less imposing.
14161416
# This message is too long to be a string in the A/UX 3.1 sh.
14171417
cat <<_ACEOF
1418-
'configure' configures c-ares 1.32.1 to adapt to many kinds of systems.
1418+
'configure' configures c-ares 1.32.2 to adapt to many kinds of systems.
14191419

14201420
Usage: $0 [OPTION]... [VAR=VALUE]...
14211421

@@ -1486,7 +1486,7 @@ fi
14861486

14871487
if test -n "$ac_init_help"; then
14881488
case $ac_init_help in
1489-
short | recursive ) echo "Configuration of c-ares 1.32.1:";;
1489+
short | recursive ) echo "Configuration of c-ares 1.32.2:";;
14901490
esac
14911491
cat <<\_ACEOF
14921492

@@ -1623,7 +1623,7 @@ fi
16231623
test -n "$ac_init_help" && exit $ac_status
16241624
if $ac_init_version; then
16251625
cat <<\_ACEOF
1626-
c-ares configure 1.32.1
1626+
c-ares configure 1.32.2
16271627
generated by GNU Autoconf 2.72
16281628

16291629
Copyright (C) 2023 Free Software Foundation, Inc.
@@ -2267,7 +2267,7 @@ cat >config.log <<_ACEOF
22672267
This file contains any messages produced by compilers while
22682268
running configure, to aid debugging if configure makes a mistake.
22692269

2270-
It was created by c-ares $as_me 1.32.1, which was
2270+
It was created by c-ares $as_me 1.32.2, which was
22712271
generated by GNU Autoconf 2.72. Invocation command line was
22722272

22732273
$ $0$ac_configure_args_raw
@@ -3259,7 +3259,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
32593259

32603260

32613261

3262-
CARES_VERSION_INFO="19:1:17"
3262+
CARES_VERSION_INFO="19:2:17"
32633263

32643264

32653265

@@ -5999,7 +5999,7 @@ fi
59995999

60006000
# Define the identity of the package.
60016001
PACKAGE='c-ares'
6002-
VERSION='1.32.1'
6002+
VERSION='1.32.2'
60036003

60046004

60056005
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -26339,7 +26339,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
2633926339
# report actual input values of CONFIG_FILES etc. instead of their
2634026340
# values after options handling.
2634126341
ac_log="
26342-
This file was extended by c-ares $as_me 1.32.1, which was
26342+
This file was extended by c-ares $as_me 1.32.2, which was
2634326343
generated by GNU Autoconf 2.72. Invocation command line was
2634426344

2634526345
CONFIG_FILES = $CONFIG_FILES
@@ -26407,7 +26407,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
2640726407
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
2640826408
ac_cs_config='$ac_cs_config_escaped'
2640926409
ac_cs_version="\\
26410-
c-ares config.status 1.32.1
26410+
c-ares config.status 1.32.2
2641126411
configured by $0, generated by GNU Autoconf 2.72,
2641226412
with options \\"\$ac_cs_config\\"
2641326413

deps/cares/configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ dnl Copyright (C) The c-ares project and its contributors
22
dnl SPDX-License-Identifier: MIT
33
AC_PREREQ([2.69])
44

5-
AC_INIT([c-ares], [1.32.1],
5+
AC_INIT([c-ares], [1.32.2],
66
[c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])
77

8-
CARES_VERSION_INFO="19:1:17"
8+
CARES_VERSION_INFO="19:2:17"
99
dnl This flag accepts an argument of the form current[:revision[:age]]. So,
1010
dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
1111
dnl 1.

deps/cares/include/ares_version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
#define ARES_VERSION_MAJOR 1
3434
#define ARES_VERSION_MINOR 32
35-
#define ARES_VERSION_PATCH 1
35+
#define ARES_VERSION_PATCH 2
3636
#define ARES_VERSION \
3737
((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \
3838
(ARES_VERSION_PATCH))
39-
#define ARES_VERSION_STR "1.32.1"
39+
#define ARES_VERSION_STR "1.32.2"
4040

4141
#define CARES_HAVE_ARES_LIBRARY_INIT 1
4242
#define CARES_HAVE_ARES_LIBRARY_CLEANUP 1

deps/cares/src/lib/Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@SET_MAKE@
1616

1717
# aminclude_static.am generated automatically by Autoconf
18-
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
18+
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024
1919

2020
# Copyright (C) The c-ares project and its contributors
2121
# SPDX-License-Identifier: MIT

deps/cares/src/lib/ares__timeval.c

+17-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@
3030

3131
void ares__tvnow(ares_timeval_t *now)
3232
{
33-
/* GetTickCount64() is available on Windows Vista and higher */
34-
ULONGLONG milliseconds = GetTickCount64();
33+
/* QueryPerformanceCounters() has been around since Windows 2000, though
34+
* significant fixes were made in later versions. Documentation states
35+
* 1 microsecond or better resolution with a rollover not less than 100 years.
36+
* This differs from GetTickCount{64}() which has a resolution between 10 and
37+
* 16 ms. */
38+
LARGE_INTEGER freq;
39+
LARGE_INTEGER current;
3540

36-
now->sec = (ares_int64_t)milliseconds / 1000;
37-
now->usec = (unsigned int)(milliseconds % 1000) * 1000;
41+
/* Not sure how long it takes to get the frequency, I see it recommended to
42+
* cache it */
43+
QueryPerformanceFrequency(&freq);
44+
QueryPerformanceCounter(&current);
45+
46+
now->sec = current.QuadPart / freq.QuadPart;
47+
/* We want to prevent overflows so we get the remainder, then multiply to
48+
* microseconds before dividing */
49+
now->usec = (unsigned int)(((current.QuadPart % freq.QuadPart) * 1000000) /
50+
freq.QuadPart);
3851
}
3952

4053
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)

deps/cares/src/lib/ares_destroy.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ void ares_destroy(ares_channel_t *channel)
3838
return;
3939
}
4040

41-
/* Disable configuration change monitoring */
41+
/* Mark as being shutdown */
42+
ares__channel_lock(channel);
43+
channel->sys_up = ARES_FALSE;
44+
ares__channel_unlock(channel);
45+
46+
/* Disable configuration change monitoring. We can't hold a lock because
47+
* some cleanup routines, such as on Windows, are synchronous operations.
48+
* What we've observed is a system config change event was triggered right
49+
* at shutdown time and it tries to take the channel lock and the destruction
50+
* waits for that event to complete before it continues so we get a channel
51+
* lock deadlock at shutdown if we hold a lock during this process. */
4252
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
4353
ares_event_thread_t *e = channel->sock_state_cb_data;
4454
if (e && e->configchg) {
@@ -47,14 +57,16 @@ void ares_destroy(ares_channel_t *channel)
4757
}
4858
}
4959

50-
/* Wait for reinit thread to exit if there was one pending */
60+
/* Wait for reinit thread to exit if there was one pending, can't be
61+
* holding a lock as the thread may take locks. */
5162
if (channel->reinit_thread != NULL) {
5263
void *rv;
5364
ares__thread_join(channel->reinit_thread, &rv);
5465
channel->reinit_thread = NULL;
5566
}
5667

57-
/* Lock because callbacks will be triggered */
68+
/* Lock because callbacks will be triggered, and any system-generated
69+
* callbacks need to hold a channel lock. */
5870
ares__channel_lock(channel);
5971

6072
/* Destroy all queries */

deps/cares/src/lib/ares_event_configchg.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
237237

238238

239239
# ifndef __WATCOMC__
240-
static void ares_event_configchg_ip_cb(PVOID CallerContext,
241-
PMIB_IPINTERFACE_ROW Row,
242-
MIB_NOTIFICATION_TYPE NotificationType)
240+
static void NETIOAPI_API_
241+
ares_event_configchg_ip_cb(PVOID CallerContext,
242+
PMIB_IPINTERFACE_ROW Row,
243+
MIB_NOTIFICATION_TYPE NotificationType)
243244
{
244245
ares_event_configchg_t *configchg = CallerContext;
245246
(void)Row;
@@ -303,8 +304,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
303304
* that didn't get triggered either.
304305
*/
305306
if (NotifyIpInterfaceChange(
306-
AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_ip_cb,
307-
*configchg, FALSE, &c->ifchg_hnd) != NO_ERROR) {
307+
AF_UNSPEC, ares_event_configchg_ip_cb,
308+
c, FALSE, &c->ifchg_hnd) != NO_ERROR) {
308309
status = ARES_ESERVFAIL;
309310
goto done;
310311
}

deps/cares/src/lib/ares_event_kqueue.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static ares_bool_t ares_evsys_kqueue_init(ares_event_thread_t *e)
9393

9494
kq->nchanges_alloc = 8;
9595
kq->changelist =
96-
ares_malloc_zero(sizeof(*kq->changelist) * kq->nchanges_alloc);
96+
ares_malloc_zero(kq->nchanges_alloc * sizeof(*kq->changelist));
9797
if (kq->changelist == NULL) {
9898
ares_evsys_kqueue_destroy(e);
9999
return ARES_FALSE;
@@ -123,8 +123,11 @@ static void ares_evsys_kqueue_enqueue(ares_evsys_kqueue_t *kq, int fd,
123123

124124
if (kq->nchanges > kq->nchanges_alloc) {
125125
kq->nchanges_alloc <<= 1;
126-
kq->changelist = ares_realloc_zero(kq->changelist, kq->nchanges_alloc >> 1,
127-
kq->nchanges_alloc);
126+
kq->changelist = ares_realloc_zero(
127+
kq->changelist,
128+
(kq->nchanges_alloc >> 1) * sizeof(*kq->changelist),
129+
kq->nchanges_alloc * sizeof(*kq->changelist)
130+
);
128131
}
129132

130133
EV_SET(&kq->changelist[idx], fd, filter, flags, 0, 0, 0);

deps/cares/src/lib/ares_event_thread.c

+40-19
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,35 @@ static void ares_event_process_updates(ares_event_thread_t *e)
262262
}
263263
}
264264

265+
static void ares_event_thread_cleanup(ares_event_thread_t *e)
266+
{
267+
/* Manually free any updates that weren't processed */
268+
if (e->ev_updates != NULL) {
269+
ares__llist_node_t *node;
270+
271+
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
272+
ares_event_destroy_cb(ares__llist_node_claim(node));
273+
}
274+
ares__llist_destroy(e->ev_updates);
275+
e->ev_updates = NULL;
276+
}
277+
278+
if (e->ev_sock_handles != NULL) {
279+
ares__htable_asvp_destroy(e->ev_sock_handles);
280+
e->ev_sock_handles = NULL;
281+
}
282+
283+
if (e->ev_cust_handles != NULL) {
284+
ares__htable_vpvp_destroy(e->ev_cust_handles);
285+
e->ev_cust_handles = NULL;
286+
}
287+
288+
if (e->ev_sys != NULL && e->ev_sys->destroy != NULL) {
289+
e->ev_sys->destroy(e);
290+
e->ev_sys = NULL;
291+
}
292+
}
293+
265294
static void *ares_event_thread(void *arg)
266295
{
267296
ares_event_thread_t *e = arg;
@@ -296,14 +325,16 @@ static void *ares_event_thread(void *arg)
296325
ares__thread_mutex_lock(e->mutex);
297326
}
298327

328+
/* Lets cleanup while we're in the thread itself */
329+
ares_event_thread_cleanup(e);
330+
299331
ares__thread_mutex_unlock(e->mutex);
332+
300333
return NULL;
301334
}
302335

303336
static void ares_event_thread_destroy_int(ares_event_thread_t *e)
304337
{
305-
ares__llist_node_t *node;
306-
307338
/* Wake thread and tell it to shutdown if it exists */
308339
ares__thread_mutex_lock(e->mutex);
309340
if (e->isup) {
@@ -314,26 +345,14 @@ static void ares_event_thread_destroy_int(ares_event_thread_t *e)
314345

315346
/* Wait for thread to shutdown */
316347
if (e->thread) {
317-
ares__thread_join(e->thread, NULL);
348+
void *rv = NULL;
349+
ares__thread_join(e->thread, &rv);
318350
e->thread = NULL;
319351
}
320352

321-
/* Manually free any updates that weren't processed */
322-
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
323-
ares_event_destroy_cb(ares__llist_node_claim(node));
324-
}
325-
ares__llist_destroy(e->ev_updates);
326-
e->ev_updates = NULL;
327-
328-
ares__htable_asvp_destroy(e->ev_sock_handles);
329-
e->ev_sock_handles = NULL;
330-
331-
ares__htable_vpvp_destroy(e->ev_cust_handles);
332-
e->ev_cust_handles = NULL;
333-
334-
if (e->ev_sys && e->ev_sys->destroy) {
335-
e->ev_sys->destroy(e);
336-
}
353+
/* If the event thread ever got to the point of starting, this is a no-op
354+
* as it runs this same cleanup when it shuts down */
355+
ares_event_thread_cleanup(e);
337356

338357
ares__thread_mutex_destroy(e->mutex);
339358
e->mutex = NULL;
@@ -350,6 +369,8 @@ void ares_event_thread_destroy(ares_channel_t *channel)
350369
}
351370

352371
ares_event_thread_destroy_int(e);
372+
channel->sock_state_cb_data = NULL;
373+
channel->sock_state_cb = NULL;
353374
}
354375

355376
static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys)

0 commit comments

Comments
 (0)