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

使用Context传入req.Do 会导致debug模式内存出错 #37

Closed
locxiang opened this issue Jun 19, 2019 · 2 comments
Closed

使用Context传入req.Do 会导致debug模式内存出错 #37

locxiang opened this issue Jun 19, 2019 · 2 comments

Comments

@locxiang
Copy link

locxiang commented Jun 19, 2019

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45d9f48]

goroutine 124 [running]:
github.com/imroc/req.(*Resp).dumpReqHead(0xc00024a580, 0xc00058b3e8)
	/Users/xh/go/pkg/mod/github.com/imroc/req@v0.2.3/dump.go:117 +0x128
github.com/imroc/req.(*Resp).dumpRequest(0xc00024a580, 0xc00058b3e8)
	/Users/xh/go/pkg/mod/github.com/imroc/req@v0.2.3/dump.go:103 +0x18f
github.com/imroc/req.(*Resp).Dump(0xc00024a580, 0x4d92d16, 0x10)
	/Users/xh/go/pkg/mod/github.com/imroc/req@v0.2.3/dump.go:206 +0xc8
github.com/imroc/req.(*Req).Do(0xc0001889a0, 0x4d89712, 0x4, 0xc0000d0000, 0x44, 0xc0005edc48, 0x4, 0x4, 0xc0005edaa8, 0x403ea3b, ...)
	/Users/xh/go/pkg/mod/github.com/imroc/req@v0.2.3/req.go:355 +0xafe
github.com/imroc/req.(*Req).Post(...)
	/Users/xh/go/pkg/mod/github.com/imroc/req@v0.2.3/req.go:621
......

调用代码

post, err := r.Post(domain, header, req.FileUpload{
		File:      file,
		FileName:  filename,
		FieldName: "file",
	}, req.UploadProgress(progress),ctx)
	if err != nil {
		return nil, err
	}

跟踪内存发现,已经释放了r.req, 但是debug模式还在调用r.req.URL,
改成非debug模式或者关闭ctx就无问题

@imroc
Copy link
Owner

imroc commented Jun 20, 2019

多谢反馈,已修复:b713f87

@imroc
Copy link
Owner

imroc commented Jun 20, 2019

打上了最新 tag v0.2.4

@imroc imroc closed this as completed Jun 20, 2019
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

No branches or pull requests

2 participants