Skip to content

net/http: go1.24.1 macOS without netgo (native) uses IPv6 instead of Dialcontext provided ipv4 #72748

Closed as not planned
@ldemailly

Description

@ldemailly

Go version

go version go1.24.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/dl/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/dl/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/fq/gng4z4915mb73r9js_422h4c0000gn/T/go-build842198577=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/dl/github/fortio.org/multicurl/go.mod'
GOMODCACHE='/Users/dl/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/dl/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/dl/sdk/go1.24.1'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/dl/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/dl/sdk/go1.24.1/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I have a debug service that is hosted on 3 different VMs

debug.fortio.org has address 192.9.227.83
debug.fortio.org has address 192.9.142.5
debug.fortio.org has address 18.222.136.83
debug.fortio.org has IPv6 address 2600:1f16:9c6:b400:282c:a766:6cab:4e82
debug.fortio.org has IPv6 address 2603:c024:c00a:d144:7cd0:4951:7106:96b8
debug.fortio.org has IPv6 address 2603:c024:c00a:d144:6663:5896:7efb:fbf3

And a tool that exercise each address - with go1.24.1 on macos 15.3.1 (24D70) with 10/10 https://test-ipv6.com
Despite using ipv4 from go, it connects using the same shared IPv6 address (thus connects to same server) and only for http (not https)

go1.24.1 run fortio.org/[email protected] -4 -loglevel debug http://debug.fortio.org # bad

vs

go1.23.7 run fortio.org/[email protected] -4 -loglevel debug http://debug.fortio.org # good

What did you see happen?

[...]
12:00:40.151 [VRB] 3: DialContext tcp debug.fortio.org:80 -> 18.222.136.83:80
12:00:40.162 [VRB] 3: DialContext 192.168.110.152:58297
12:00:40.174 [INF] 3: Status 200 "200 OK" from 18.222.136.83
⣻  364 b, 0s elapsed, 378.558 Mb/s
Φορτίο version 1.68.0 h1:2M9RuitiN+MgW6QlTJCHjW6PJLAPj/YCXegxSCLQ3rw= go1.23.6 arm64 linux (in fortio.org/proxy 1.21.0)
Debug server on oa1 up for 410h1m50.3s
Request from [2600:1700:1151:b24f:1d44:d45:bb10:ec89]:58297

Ie it connects to the wrong server using ipv6 instead of the specified ipv4

To reduce the output:

$ go1.24.1 run fortio.org/[email protected] -4 -loglevel debug http://debug.fortio.org 2> /dev/null | grep "server on"
Debug server on ol1 up for 409h51m40.3s
Debug server on ol1 up for 409h51m40.4s
Debug server on ol1 up for 409h51m40.5s

3 times the same server

What did you expect to see?

Same as go1.23 (or -tags netgo)

$ go1.23.7 run fortio.org/[email protected] -4 -loglevel debug http://debug.fortio.org 2> /dev/null | grep "server on"
Debug server on ol1 up for 409h52m36.8s
Debug server on oa1 up for 410h5m18.7s
Debug server on a1 up for 409h58m47.4s

3 different servers

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions