Skip to content

Conversation

@LibreAgent2025
Copy link

@LibreAgent2025 LibreAgent2025 commented Jan 5, 2026

What type of PR is this?

fix

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

当seqID==0时传入一个空的配置,避免出现panic

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):
server和client同时启动多路复用,关闭server服务时client会触发panic #1897

  1. 触发场景: 当服务端关闭时,会向客户端发送一个 seqID=0 的控制帧。
  2. 进入控制帧处理逻辑: 客户端的 muxCliConn.OnRequest 收到该帧,因 seqID 为 0,进入控制帧处理逻辑。
    源码路径: kitex/pkg/remote/trans/netpollmux/mux_conn.go
    ri := rpcinfo.NewRPCInfo(nil, nil, iv, nil, nil) // 关键点:第 4 个参数 config 为 nil

在这里,为了解码控制帧,代码创建了一个临时的 RPCInfo 实例 (ri)。关键在于,NewRPCInfo 的第四个参数 config 被传入了 nil。这意味着这个临时 Message 的 RPCInfo 中 Config() 返回的是 nil。
3. 解码调用链: 接着,代码调用 defaultCodec.Decode(ctx, msg, bufReader)。Decode 内部会调用 DecodePayload。
源码路径: kitex/pkg/remote/codec/default_codec.go
// kitex/pkg/remote/codec/default_codec.go:256

// kitex/pkg/remote/codec/default_codec.go:234

  1. GetPayloadCodec 内部逻辑与 Panic 点: GetPayloadCodec 尝试获取 PayloadCodec。
    源码路径: kitex/pkg/remote/payload_codec.go
    // kitex/pkg/remote/payload_codec.go:36
  • 对于控制帧的 Message,message.PayloadCodec() 是 nil。
  • 代码执行到 ri.Config().PayloadCodec()。
  • 由于步骤 2 中创建 RPCInfo 时传入的 config 是 nil,所以 ri.Config() 返回 nil。
  • 在 nil 上调用 PayloadCodec() 方法,触发了空指针解引用 panic。

(Optional) Which issue(s) this PR fixes:

Fixes #1897

(optional) The PR that updates user documentation:

@LibreAgent2025 LibreAgent2025 requested review from a team as code owners January 5, 2026 11:58
@CLAassistant
Copy link

CLAassistant commented Jan 5, 2026

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

server和client同时启动多路复用,关闭server服务时client会触发panic

2 participants