Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection outPutAck 在事件循环里发生panic #355

Open
someview opened this issue Aug 16, 2024 · 3 comments
Open

connection outPutAck 在事件循环里发生panic #355

someview opened this issue Aug 16, 2024 · 3 comments

Comments

@someview
Copy link

我们在使用read-throttle的分支,发现eventloop崩溃了。
track

原因在于:

	if triggerWrite {
				if operator.OnWrite != nil {
					// for non-connection
					operator.OnWrite(p)
				} else {
					// only for connection
					var bs, supportZeroCopy = operator.Outputs(barriers[i].bs)
					if len(bs) > 0 {
						// TODO: Let the upper layer pass in whether to use ZeroCopy.
						var n, err = iosend(operator.FD, bs, barriers[i].ivs, false && supportZeroCopy)
						operator.OutputAck(n)
						if err != nil {
							p.appendHup(operator)
							continue
						}
					}
				}
			}
			operator.done()
		}

上述这段代码在read-throttle和develop分支是一样的。触发bug的原因是,添加限流以后,var n, err = iosend(operator.FD, bs, barriers[i].ivs, false && supportZeroCopy) 触发了内核关闭连接,然而这里没有对iosend返回的错误进行判断(可能连接已经不可用了),直接outputAck了,导致panic.

@someview
Copy link
Author

照这个逻辑,devlop分支也有这个bug,在这里提个issue.

@joway
Copy link
Member

joway commented Aug 19, 2024

@someview 你 panic stack 能贴完整吗?error != nil 时,n 为0,讲道理也不会panic

@someview
Copy link
Author

@someview 你 panic stack 能贴完整吗?error != nil 时,n 为0,讲道理也不会panic

这个很好触发,只要让操作系统因为tcp缓冲区溢出的同时,还有并发读写。eventloop就panic了。具体的代码可能等我和前同事沟通一下,跑路了

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

No branches or pull requests

2 participants