pipedv1: stopSignal handler panics on closed channel upon concurrent or duplicate signal calls
维护者通常 1 天内回复
@darshpatel1052 已经在做这个了。
开始于 2026年11月16日。
评估
调研方向
从 pkg/app/pipedv1/controller/stopsignal.go 第 70-91 行附近开始,其中 Cancel()、Timeout() 和 Terminate() 各自向 s.ch 发送,然后关闭它;阅读 NewStopSignal(),了解 channel 和 atomic.String 是如何设置的。用 sync.Once 保护发送路径(先设置 signal 并取消,然后恰好发送并关闭一次),并确认 pkg/app/pipedv1/controller/scheduler.go:370-395 中的消费者仍然收到一个值。将报告中的 TestStopSignal_Idempotency 用例添加到 controller 包的测试中,并运行 go test ./pkg/app/pipedv1/controller/...;完成意味着重复或并发调用不会 panic,并且 channel 只关闭一次。
由索引模型根据 Issue 内容生成。
描述
What happened:
In pkg/app/pipedv1/controller/stopsignal.go:70-91, Cancel(), Timeout(), and Terminate() directly send to s.ch and call close(s.ch):
func (s *stopSignal) Cancel() {
s.signal.Store(string(StopSignalCancel))
s.cancel()
s.ch <- StopSignalCancel
close(s.ch)
}
func (s *stopSignal) Timeout() {
s.signal.Store(string(StopSignalTimeout))
s.cancel()
s.ch <- StopSignalTimeout
close(s.ch)
}
func (s *stopSignal) Terminate() {
s.signal.Store(string(StopSignalTerminate))
s.cancel()
s.ch <- StopSignalTerminate
close(s.ch)
}
Although s.signal is an atomic.String, the channel operations (s.ch <- ... and close(s.ch)) are not guarded against multiple executions.
During stage execution (pkg/app/pipedv1/controller/scheduler.go:370-395), stage completion/cancellation is selected across multiple event sources: ctx.Done(), timer.C (deployment timeout), timeout (stage timeout), and s.cancelledCh (user cancellation):
select {
case <-ctx.Done():
handler.Terminate()
<-doneCh
case <-timer.C:
handler.Timeout()
<-doneCh
case cmd := <-s.cancelledCh:
...
handler.Cancel()
<-doneCh
case <-timeout:
handler.Timeout()
<-doneCh
case <-doneCh:
break
}
If multiple signals arrive around the same time, or if Cancel/Timeout are called more than once:
- Writing to
s.chafter it was closed triggerspanic: send on closed channel. - Calling
close(s.ch)a second time triggerspanic: close of closed channel.
Because this panic occurs inside the stage runner goroutine, it terminates the piped process.
What you expected to happen:
All signal emission methods (Cancel(), Timeout(), Terminate()) should be idempotent and thread-safe (e.g. using a sync.Once inside stopSignal). The first signal should register and close the channel, and subsequent invocations should safely return without panicking.
How to reproduce it:
The panic can be triggered with a two-line test:
func TestStopSignal_Idempotency(t *testing.T) {
_, handler := NewStopSignal()
handler.Timeout()
handler.Cancel() // Panics immediately with: panic: send on closed channel
}
Environment:
pipedversion: master (commit 5dc13c2), pipedv1control-planeversion: master- Others: N/A
- 主要语言
- Go
- 星标
- 1.4k
- 派生
- 403
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 40
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pipe-cd/pipecd 的其他 Issue
-
kind/bug
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
pipedv1 Terraform plugin fails to parse plans that invoke actions可能已有人在做 @abhiraj75 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Add a community meetings calendar to the website可能已有人在做 @Dhirenderchoudhary 于 8 天前认领。 未关闭area/docs community good first issue
难度 2/5 半天 新手友好度 65/100
pipe-cd/pipecd#7648 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
pipedv1: deployment remains stuck in PENDING when deploy source preparation fails in planner可能已有人在做 @vikash7485 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
相似的 Issue
-
hive
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
/v1/chat/completions logprobs leave out top_logprobs when none are requested可能已有人在做 @Shizoqua 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
service stage:spec
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug(terraform): a `kubernetes_manifest` the scan can't fully read is dropped and nothing says so可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复