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

解析cookie报数组越界,猜测是并发问题导致 #1228

Closed
leoperfect opened this issue Nov 12, 2024 · 1 comment
Closed

解析cookie报数组越界,猜测是并发问题导致 #1228

leoperfect opened this issue Nov 12, 2024 · 1 comment
Labels
invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) stale

Comments

@leoperfect
Copy link

线上偶现panic,报错如下
slice bounds out of range [94:93],错误在 copy(h.h[i:], h.h[i+1:])这一行。 这一行的作用是将当前遍历的cookie移除,不应该会数组越界才对,下面是源码部分。

func (h *RequestHeader) collectCookies() {
	if h.cookiesCollected {
		return
	}
        for i, n := 0, len(h.h); i < n; i++ {
		kv := &h.h[i]
		if bytes.Equal(kv.key, bytestr.StrCookie) {
			h.cookies = parseRequestCookies(h.cookies, kv.value)
			tmp := *kv
			copy(h.h[i:], h.h[i+1:])
			n--
			i--
			h.h[n] = tmp
			h.h = h.h[:n]
		}
	}
	h.cookiesCollected = true
}
@github-actions github-actions bot added the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Nov 12, 2024
Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@github-actions github-actions bot added the stale label Nov 12, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) stale
Development

No branches or pull requests

1 participant