Skip to content

Hysteria: prevent crash on cnc.Connection#6320

Open
hossinasaadi wants to merge 6 commits into
XTLS:mainfrom
hossinasaadi:patch-hy2
Open

Hysteria: prevent crash on cnc.Connection#6320
hossinasaadi wants to merge 6 commits into
XTLS:mainfrom
hossinasaadi:patch-hy2

Conversation

@hossinasaadi

Copy link
Copy Markdown
Contributor

No description provided.

@Fangliding

Copy link
Copy Markdown
Member

有任何通向这个panic的实质路径吗?

@hossinasaadi

Copy link
Copy Markdown
Contributor Author

有任何通向这个panic的实质路径吗?

This panic occasionally occurs on the client side and has been observed in real-world user crash reports. Since it can destabilize the client and lead to crashes, it’s not merely a theoretical issue.

@Fangliding

Copy link
Copy Markdown
Member

panic抛出的栈呢

@hossinasaadi

Copy link
Copy Markdown
Contributor Author

panic抛出的栈呢

this will triggered when Hysteria is used with dialerProxy pointing to a SOCKS outbound. The stack trace points to dial() during the outbound dial path.

panic: *cnc.Connection

goroutine 144 [running]:
github.com/xtls/xray-core/transport/internet/hysteria.(*client).dial(0x10b42ef50, {0x107cde5f0, 0x10b6cc7e0})
	github.com/xtls/xray-core/transport/internet/hysteria/dialer.go:150 +0xfa0
github.com/xtls/xray-core/transport/internet/hysteria.(*client).tcp(0x10b42ef50, {0x107cde5f0?, 0x10b6cc7e0?})
	github.com/xtls/xray-core/transport/internet/hysteria/dialer.go:260 +0xbc
github.com/xtls/xray-core/transport/internet/hysteria.Dial({0x107cde5f0, 0x10b6cc7e0}, {{0x107cde7f8?, 0x10b67e2d8?}, 0x1?, 0x0?}, 0x10b430770)
	github.com/xtls/xray-core/transport/internet/hysteria/dialer.go:365 +0x3c4
github.com/xtls/xray-core/transport/internet.Dial({0x107cde5f0, 0x10b6cc7e0}, {{0x107cde7f8?, 0x10b67e2d8?}, 0xe2d8?, 0x1?}, 0x105a98b04?)
	github.com/xtls/xray-core/transport/internet/dialer.go:63 +0x140
github.com/xtls/xray-core/app/proxyman/outbound.(*Handler).Dial(0x104a7bc20, {0x107cde5f0, 0x10b6cc7e0}, {{0x107cde7f8, 0x10b67e2d8}, 0x1bb, 0x2})
	github.com/xtls/xray-core/app/proxyman/outbound/handler.go:316 +0x72c
github.com/xtls/xray-core/proxy/hysteria.(*Client).Process(0x104b64690, {0x107cde5f0, 0x104b26f60}, 0x122204720, {0x107cdba30, 0x104a7bc20})
	github.com/xtls/xray-core/proxy/hysteria/client.go:58 +0x158
github.com/xtls/xray-core/app/proxyman/outbound.(*Handler).Dispatch(0x104a7bc20, {0x107cde5f0, 0x104b26f60}, 0x122204720)
	github.com/xtls/xray-core/app/proxyman/outbound/handler.go:242 +0x844
github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).routedDispatch(0x122201a40, {0x107cde5f0, 0x104b26f60}, 0x122204720, {{0x107cde868, 0x1049d8130}, 0x1bb, 0x2})
	github.com/xtls/xray-core/app/dispatcher/default.go:504 +0x8b0
created by github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).Dispatch in goroutine 143
	github.com/xtls/xray-core/app/dispatcher/default.go:288 +0x464

@LjhAUMEM

Copy link
Copy Markdown
Collaborator

当初没给 udphop 配链式是故意的,你要是想配就只加那一部分,panic 部分不要改动,因为不止这一处

@LjhAUMEM

Copy link
Copy Markdown
Collaborator

唉,真要配链式结构又要调整,@hossinasaadi 我将直接push到你的branch,没问题吧?

@hossinasaadi

Copy link
Copy Markdown
Contributor Author

唉,真要配链式结构又要调整,@hossinasaadi 我将直接push到你的branch,没问题吧?

Thanks for checking. Sure, no problem. Feel free to push

@hossinasaadi

Copy link
Copy Markdown
Contributor Author

@LjhAUMEM I’ve fixed the chaining issue, although I’m not entirely sure whether it could affect other parts of the codebase. It works correctly in my testing, so it might be helpful.
hossinasaadi@0cf1b86

@LjhAUMEM

LjhAUMEM commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@LjhAUMEM I’ve fixed the chaining issue, although I’m not entirely sure whether it could affect other parts of the codebase. It works correctly in my testing, so it might be helpful. hossinasaadi@0cf1b86

链式没问题啊,你修啥,还有一些不必要的 rename 一些变量...

当初没适配链式是因为使用场景有限,以及 sysconn 的问题,你今天提了加就加吧,等我这边提交

@hossinasaadi

Copy link
Copy Markdown
Contributor Author

链式没问题啊,你修啥,还有一些不必要的 rename 一些变量...

当初没适配链式是因为使用场景有限,你今天提了加就加吧,等我这边提交

Thanks, I’ve reverted the unnecessary renamings.

I fixed the Hysteria → SOCKS5 chaining issue when using either dialerProxy or proxySettings. This was the scenario that was triggering the panic I encountered.

@LjhAUMEM LjhAUMEM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LjhAUMEM

Copy link
Copy Markdown
Collaborator

@RPRX 与这个 pr 无关,udpHop 可以加 address sockopt 两个字段来移到 mask,但还不确定要不要这么做

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants