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

panic: runtime error: invalid memory address or nil pointer dereference #59

Open
joaolsilva opened this issue Aug 3, 2017 · 0 comments

Comments

@joaolsilva
Copy link

joaolsilva commented Aug 3, 2017

Is go-curl thread safe? I've hit two panics one in goCallProgressFunction other in goCallWriteFunction after making concurrent requests in goroutines.

Code to replicate: https://gist.github.com/joaolsilva/bc4d73122049d6fe5bb9e2d79f81579c

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

goroutine 424 [running]:
github.com/andelf/go-curl.goCallProgressFunction(0x0, 0x0, 0x0, 0x0, 0x4886c00, 0x0)
/Users/jsilva/go/src/github.com/andelf/go-curl/callback.go:40 +0x40
github.com/andelf/go-curl._cgoexpwrap_b3b701c3ac65_goCallProgressFunction(0x0, 0x0, 0x0, 0x0, 0x4886c00, 0x4886c00)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:1449 +0x5b
github.com/andelf/go-curl._Cfunc_curl_easy_cleanup(0x4886c00)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:668 +0x41
github.com/andelf/go-curl.(*CURL).Cleanup.func1(0x4886c00)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:163 +0x60
github.com/andelf/go-curl.(*CURL).Cleanup(0xc4200edae0)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:163 +0x33
panic(0x40bd760, 0x4146c40)
/usr/local/Cellar/go/1.8.3/libexec/src/runtime/panic.go:489 +0x2cf
github.com/andelf/go-curl.goCallProgressFunction(0x0, 0x0, 0x0, 0x0, 0x4886c00, 0x0)
/Users/jsilva/go/src/github.com/andelf/go-curl/callback.go:40 +0x40
github.com/andelf/go-curl._cgoexpwrap_b3b701c3ac65_goCallProgressFunction(0x0, 0x0, 0x0, 0x0, 0x4886c00, 0x0)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:1449 +0x5b
github.com/andelf/go-curl._Cfunc_curl_easy_perform(0x4886c00, 0x0)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:795 +0x49
github.com/andelf/go-curl.(*CURL).Perform.func1(0x4886c00, 0x10)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:344 +0x60
github.com/andelf/go-curl.(*CURL).Perform(0xc4200edae0, 0x4e58, 0x40be540)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:344 +0x2e
main.GetURL(0x40dd2d0, 0x43, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/jsilva/go/src/curl-crash/curl-crash.go:56 +0x4a1
created by main.main
/Users/jsilva/go/src/curl-crash/curl-crash.go:81 +0x97

If the progress func is removed the crash happens in the write func

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

goroutine 2434 [running]:
github.com/andelf/go-curl.goCallWriteFunction(0x8faf460, 0x867, 0x8f6fa00, 0xc400000008)
/Users/jsilva/go/src/github.com/andelf/go-curl/callback.go:31 +0x61
github.com/andelf/go-curl._cgoexpwrap_b3b701c3ac65_goCallWriteFunction(0x8faf460, 0x867, 0x8f6fa00, 0x0)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:1436 +0x72
github.com/andelf/go-curl._Cfunc_curl_easy_perform(0x8f6fa00, 0x0)
github.com/andelf/go-curl/_obj/_cgo_gotypes.go:795 +0x49
github.com/andelf/go-curl.(*CURL).Perform.func1(0x8f6fa00, 0x20)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:344 +0x60
github.com/andelf/go-curl.(*CURL).Perform(0xc422e40460, 0x4e2b, 0x40bba20)
/Users/jsilva/go/src/github.com/andelf/go-curl/easy.go:344 +0x2e
main.GetURL(0x40dd350, 0x43, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/jsilva/go/src/curl-crash/curl-crash.go:58 +0x404
created by main.main
/Users/jsilva/go/src/curl-crash/curl-crash.go:83 +0x97

Before crashing it also prints "curl: Couldn't resolve host name". This error doesn't happen if only a request is made at a time.

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

1 participant