This is an automated email from the ASF dual-hosted git repository.
leborchuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new d6a7c13f6d5 Fix IPv6 crash: drop dead HAVE_IPV6 guards left after PG16
merge (#1946)
d6a7c13f6d5 is described below
commit d6a7c13f6d5594f3faae7ef5b93c76dbebfc5b24
Author: Leonid <[email protected]>
AuthorDate: Fri Sep 11 19:21:41 2026 +0300
Fix IPv6 crash: drop dead HAVE_IPV6 guards left after PG16 merge (#1946)
Upstream PostgreSQL commit "Remove configure probe for sockaddr_in6 and
require AF_INET6." (bcc8b14) deleted the HAVE_IPV6 probe and stripped the
#ifdef HAVE_IPV6 guards from its own code, since AF_INET6 is now always
available. Cloudberry-specific code still gated IPv6 handling behind
#ifdef HAVE_IPV6, so after the PG16 merge those blocks became dead code:
HAVE_IPV6 is never defined on non-Windows builds.
The practical effect: on an IPv6-only cluster, getDnsCachedAddress() never
populates its cache entry (the IPv6 branch was compiled out), then returns
e->hostinfo with e == NULL -- a bogus non-NULL pointer (offsetof key[]) --
which the caller passes to pstrdup(), crashing in strlen(). This shows up
as a coordinator/FtsProbe SIGSEGV:
#0 __strlen_evex
#1 MemoryContextStrdup
#2 getCdbComponentInfo
#3 cdbcomponent_getCdbComponents
#4 FtsProbeMain
Remove the leftover #ifdef HAVE_IPV6 guards so the IPv6 paths compile
unconditionally, matching what upstream did to its own files. Also guard
the cache return against a NULL entry so an unresolvable segment logs a
clean "cannot resolve network address" error instead of segfaulting.
Files: cdbutil.c (both getDnsCachedAddress copies), auth.c, and the
interconnect listener setup (ic_common.c, ic_tcp.c, ic_udpifc.c).
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
---
contrib/interconnect/ic_common.c | 2 --
contrib/interconnect/tcp/ic_tcp.c | 2 --
contrib/interconnect/udp/ic_udpifc.c | 2 --
src/backend/cdb/cdbutil.c | 10 ++--------
src/backend/libpq/auth.c | 2 --
5 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/contrib/interconnect/ic_common.c b/contrib/interconnect/ic_common.c
index 7e266b69efb..4195354f538 100644
--- a/contrib/interconnect/ic_common.c
+++ b/contrib/interconnect/ic_common.c
@@ -406,11 +406,9 @@ format_sockaddr(struct sockaddr_storage *sa, char *buf,
size_t len)
snprintf(buf, len, "?host?:?port?");
else
{
-#ifdef HAVE_IPV6
if (sa->ss_family == AF_INET6)
snprintf(buf, len, "[%s]:%s", remote_host, remote_port);
else
-#endif
snprintf(buf, len, "%s:%s", remote_host, remote_port);
}
diff --git a/contrib/interconnect/tcp/ic_tcp.c
b/contrib/interconnect/tcp/ic_tcp.c
index a3855c87771..5f7c8ffc6e1 100644
--- a/contrib/interconnect/tcp/ic_tcp.c
+++ b/contrib/interconnect/tcp/ic_tcp.c
@@ -183,7 +183,6 @@ setupTCPListeningSocket(int backlog, int *listenerSocketFd,
int32 *listenerPort)
* this machine supports IPv6 and IPv6 is enabled, but we don't know
that.
*/
-#ifdef HAVE_IPV6
if (addrs->ai_family == AF_INET && addrs->ai_next != NULL &&
addrs->ai_next->ai_family == AF_INET6)
{
/*
@@ -201,7 +200,6 @@ setupTCPListeningSocket(int backlog, int *listenerSocketFd,
int32 *listenerPort)
temp->ai_next = addrs; /* point second node to first */
addrs = temp; /* start the list with the old
second node */
}
-#endif
for (rp = addrs; rp != NULL; rp = rp->ai_next)
{
diff --git a/contrib/interconnect/udp/ic_udpifc.c
b/contrib/interconnect/udp/ic_udpifc.c
index 0f23ecaad8e..d00c4f7727b 100644
--- a/contrib/interconnect/udp/ic_udpifc.c
+++ b/contrib/interconnect/udp/ic_udpifc.c
@@ -1666,7 +1666,6 @@ setupUDPListeningSocket(int *listenerSocketFd, int32
*listenerPort, int *txFamil
*/
#ifndef __darwin__
-#ifdef HAVE_IPV6
if (addrs->ai_family == AF_INET && addrs->ai_next != NULL &&
addrs->ai_next->ai_family == AF_INET6)
{
/*
@@ -1685,7 +1684,6 @@ setupUDPListeningSocket(int *listenerSocketFd, int32
*listenerPort, int *txFamil
addrs = temp; /* start the list with the old
second node */
elog(DEBUG1, "Have both IPv6 and IPv4 choices");
}
-#endif
#endif
for (rp = addrs; rp != NULL; rp = rp->ai_next)
diff --git a/src/backend/cdb/cdbutil.c b/src/backend/cdb/cdbutil.c
index cf924afae65..c4170073309 100644
--- a/src/backend/cdb/cdbutil.c
+++ b/src/backend/cdb/cdbutil.c
@@ -1369,8 +1369,6 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
}
}
-#ifdef HAVE_IPV6
-
/*
* IPv6 probably would work fine, we'd just need to make sure
all the
* data structures are big enough for the IPv6 address. And on
some
@@ -1397,7 +1395,6 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
memcpy(e->hostinfo, hostinfo, sizeof(hostinfo));
}
}
-#endif
if (use_cache)
MemoryContextSwitchTo(oldContext);
@@ -1407,7 +1404,7 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
/* return a pointer to our cache. */
if (use_cache)
- return e->hostinfo;
+ return e ? e->hostinfo : NULL;
return pstrdup(hostinfo);
}
@@ -3752,8 +3749,6 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
}
}
-#ifdef HAVE_IPV6
-
/*
* IPv6 probably would work fine, we'd just need to make sure
all the
* data structures are big enough for the IPv6 address. And on
some
@@ -3780,7 +3775,6 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
memcpy(e->hostinfo, hostinfo, sizeof(hostinfo));
}
}
-#endif
if (use_cache)
MemoryContextSwitchTo(oldContext);
@@ -3790,7 +3784,7 @@ getDnsCachedAddress(char *name, int port, int elevel,
bool use_cache)
/* return a pointer to our cache. */
if (use_cache)
- return e->hostinfo;
+ return e ? e->hostinfo : NULL;
return pstrdup(hostinfo);
}
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index b6021e169dd..f044724a13a 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -580,9 +580,7 @@ internal_client_authentication(Port *port)
* a free pass.
*/
if (port->raddr.addr.ss_family == AF_INET
-#ifdef HAVE_IPV6
|| port->raddr.addr.ss_family == AF_INET6
-#endif /* HAVE_IPV6 */
)
{
if (check_same_host_or_net(&port->raddr, ipCmpSameHost))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]