Panic upon unmarshalling `infra/conf.UdpHop.PortList`
Integrity requirements
- [x] I have read all the comments in the issue template and ensured that this issue meet the requirements.
- [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- [x] I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- [x] I searched issues and did not find any similar issues.
- [x] The problem can be successfully reproduced in the latest Release
Description
Xray panics when it tries to unmarshal a particular field. I know it's not supposed to be set to nil, but that is the default value it gets marshalled to by json.Marshal when given the infra/conf.UdpHop struct.
Xray usually handles default values by acting as if the field wasn't set at all (libXray relies on this), so this is likely a bug.
Reproduction Method
- Run xray with the provided config
- Panic
Client config
N/A
Server config
inbounds:
- port:
streamSettings:
finalmask:
quicParams:
udpHop:
ports: null
Client log
N/A
Server log
Xray 26.4.25 (Xray, Penetrates Everything.) Custom (go1.26.2 linux/amd64)
A unified platform for anti-censorship.
2026/05/03 17:10:08.472364 [Info] infra/conf/serial: Reading config: &{Name:config.yaml Format:yaml}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x110b75f]
goroutine 1 [running]:
github.com/xtls/xray-core/infra/conf.(*PortList).Build(...)
github.com/xtls/xray-core/infra/conf/common.go:217
github.com/xtls/xray-core/infra/conf.(*StreamConfig).Build(0x3b33166bc2d0)
github.com/xtls/xray-core/infra/conf/transport_internet.go:2193 +0x1d1f
github.com/xtls/xray-core/infra/conf.(*InboundDetourConfig).Build(0x3b33166ffa48)
github.com/xtls/xray-core/infra/conf/xray.go:171 +0x42e
github.com/xtls/xray-core/infra/conf.(*Config).Build(0x3b331670be00)
github.com/xtls/xray-core/infra/conf/xray.go:609 +0x13dc
github.com/xtls/xray-core/infra/conf/serial.BuildConfig({0x3b33165944f0?, 0x7088bc31f4c0?, 0x7088bc327c00?})
github.com/xtls/xray-core/infra/conf/serial/builder.go:52 +0x2a
github.com/xtls/xray-core/core.LoadConfig({0x158c9ed, 0x4}, {0x12d9ec0?, 0x3b33165a5530?})
github.com/xtls/xray-core/core/config.go:150 +0x56e
main.startXray()
github.com/xtls/xray-core/main/run.go:215 +0x8f
main.executeRun(0x22ebf20?, {0x3b33165d2120?, 0x1f?, 0x8003316601f38?})
github.com/xtls/xray-core/main/run.go:78 +0x54
github.com/xtls/xray-core/main/commands/base.Execute()
github.com/xtls/xray-core/main/commands/base/execute.go:64 +0x59f
main.main()
github.com/xtls/xray-core/main/main.go:22 +0x1a5
@LjhAUMEM ~~修一下这个发版了~~
看了下代码应该是配置解析 transport_internet.go err == nil 但 hop 仍为 nil,导致 Build() 内 dereference 取 Range 时 panic
var hop *PortList
if err := json.Unmarshal(c.FinalMask.QuicParams.UdpHop.PortList, &hop); err != nil {
hop = &PortList{}
}
UdpHop: &internet.UdpHop{
Ports: hop.Build().Ports(),
IntervalMin: inertvalMin,
IntervalMax: inertvalMax,
},
看到nil返回err不就是了
~~不对,for range nil 应该没问题的,应该是因为第一部分没 err 但 hop 还是 nil,所以 dereference 取里面的 Range 时炸了~~
~手填null吗,奇怪的需求~
看了下 ports 没有去重,不过应该没事