Repository navigation
Description
Panic in splithttp.Dial on nil DownloadSettings.Destination
Summary
transport/internet/splithttp/dialer.go:415 dereferences memory2.Destination without a nil check, causing a SIGSEGV when DownloadSettings.Destination is unset. The code carries a literal // just panic comment on that line, suggesting the panic path is known but not handled.
Impact
Any config that specifies downloadSettings on an XHTTP outbound but omits a valid Destination in the resulting MemoryStreamConfig crashes xray-core on the first dial through that outbound. In routing.balancers + burstObservatory deployments with multiple XHTTP outbounds, the crash happens at startup when the observatory begins its first probe sweep — taking the whole process down on native platforms, silently killing the probe goroutine on gomobile (iOS/Android) and leaving the corresponding outbound permanently "dead" in the observer's map.
Observed on:
- xray-core:
v26.4.13, also reproduced againstmainas of3f608b3a(diff = 0 ondialer.gosincev26.4.13) - Go:
go1.26.1 darwin/arm64 - Platform: macOS 26.4 (native binary) and iOS 26 (via
gomobile→RayCore.xcframework)
Reproduction
- Take any sing-box-format subscription with an XHTTP outbound whose
transport.downloadSettingsuses the sing-box shape ({path, host, headers, tls}) rather than the xray-core shape ({address, port, network, security, streamSettings}). - Convert to an xray-core config with
routing.balancers[0].selectorthat includes that XHTTP outbound and aburstObservatoryblock that probes it. xray run -config <config>— xray starts fine.- First traffic through the SOCKS inbound (or first observatory probe) → SEGV.
Minimal reproducer config emitting just the broken field:
{
"inbounds": [{"tag":"s","listen":"127.0.0.1","port":10808,"protocol":"socks","settings":{"auth":"noauth"}}],
"outbounds": [{
"tag": "x",
"protocol": "vless",
"settings": {"vnext":[{"address":"example.com","port":443,"users":[{"id":"...","encryption":"none"}]}]},
"streamSettings": {
"network": "xhttp",
"security": "tls",
"tlsSettings": {"serverName":"example.com","allowInsecure":true},
"xhttpSettings": {
"path": "/p",
"host": "example.com",
"mode": "auto",
"downloadSettings": {
"path": "/p",
"host": "example.com"
}
}
}
}, {"tag":"d","protocol":"freedom"}],
"routing": {"rules":[{"type":"field","inboundTag":["s"],"outboundTag":"x"}]}
}The xhttpSettings.downloadSettings sub-object here has no address/port — ToMemoryStreamConfig produces a MemoryStreamConfig where Destination ends up nil, and dialer.go:415 dereferences it.
Stack trace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x100cd5044]
goroutine 99 [running]:
github.com/xtls/xray-core/transport/internet/splithttp.Dial(...)
github.com/xtls/xray-core/transport/internet/splithttp/dialer.go:415 +0x734
github.com/xtls/xray-core/app/proxyman/outbound.(*Handler).Dispatch(...)
github.com/xtls/xray-core/app/proxyman/outbound/handler.go:242 +0x840
github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).routedDispatch(...)
github.com/xtls/xray-core/app/dispatcher/default.go:518 +0x8ac
Offending code
transport/internet/splithttp/dialer.go, around line 406-415:
if transportConfiguration.DownloadSettings != nil {
globalDialerAccess.Lock()
if streamSettings.DownloadSettings == nil {
streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings))
if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.Penetrate {
streamSettings.DownloadSettings.SocketSettings = streamSettings.SocketSettings
}
}
globalDialerAccess.Unlock()
memory2 := streamSettings.DownloadSettings
dest2 := *memory2.Destination // just panic ← line 415ToMemoryStreamConfig can legally produce a MemoryStreamConfig with a nil Destination when the input StreamConfig.Address is empty, which happens whenever the caller's DownloadSettings was constructed from a config that didn't supply an address (e.g., sing-box-format subscriptions piped through gateways that don't translate downloadSettings into xray's full stream-config shape).
Suggested fix
Return an error instead of panicking:
memory2 := streamSettings.DownloadSettings
if memory2 == nil || memory2.Destination == nil {
return nil, errors.New("splithttp: downloadSettings produced no Destination").AtWarning()
}
dest2 := *memory2.DestinationThis fails the dial gracefully (the outbound is marked dead by the dispatcher, the balancer/observatory marks it unavailable, and the process stays up for all other outbounds).
Optionally, fall back to the upload-side dest when dest2 would be nil:
var dest2 net.Destination
if memory2 != nil && memory2.Destination != nil {
dest2 = *memory2.Destination
} else {
// H2/H3 split-channel requested but no explicit download destination —
// fall back to the upload-side destination (same server, one channel).
dest2 = dest
}I can submit a PR with either variant; happy to take direction from maintainers on which semantic is preferred.
Workaround (if you hit this in the wild)
Until the fix lands, either:
- Strip
downloadSettingsfrom your XHTTP outbounds (loses H2/H3 split-channel; falls back to packet-up / stream-up mode), or - Exclude XHTTP outbounds from
routing.balancers.selectorwhen there are ≥2 of them (single XHTTP outbound won't hit the concurrent-probe race).
Activity
Fangliding commentedon Apr 22, 2026
"just panic"