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

Nil pointer panic with go 1.8.1 #45

Closed
candlerb opened this issue Apr 12, 2017 · 3 comments
Closed

Nil pointer panic with go 1.8.1 #45

candlerb opened this issue Apr 12, 2017 · 3 comments

Comments

@candlerb
Copy link

candlerb commented Apr 12, 2017

This is with Ubuntu 16.04 with the "official" go 1.8.1 distribution in /usr/local/go

I am trying to run the example code at https://github.com/nimajalali/go-force/blob/master/README.md

$ go run test-force.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x60ee96]

goroutine 1 [running]:
github.com/nimajalali/go-force/force.(*ForceApi).GetSObject(0xc420058240, 0x69a5e8, 0xe, 0x0, 0x0, 0x0, 0x7a4c40, 0xc4200188f0, 0x699eb7, 0xc)
	/home/ubuntu/go/src/github.com/nimajalali/go-force/force/sobjects.go:75 +0x86
main.main()
	/home/ubuntu/go/src/test-force/test-force.go:45 +0x1a5
exit status 2

Attempting to get a bit more info with gdb:

go build -gcflags "-N -l"
...
gdb -d $(go env GOROOT) ./test-force
...
run
...
[Switching to Thread 0x7ffff67ee700 (LWP 5972)]
0x000000000060ee96 in github.com/nimajalali/go-force/force.(*ForceApi).GetSObject (
    forceApi=0xc420058240, id=..., fields=..., out=..., err=...)
    at /home/ubuntu/go/src/github.com/nimajalali/go-force/force/sobjects.go:75
75		uri := strings.Replace(forceApi.apiSObjects[out.ApiName()].URLs[rowTemplateKey], idKey, id, 1)
(gdb) info args
forceApi = 0xc420058240
id = 0x69a5e8 "Your-Object-ID"
fields = {array = 0x0, len = 0, cap = 0}
out = {tab = 0x7a4c40 <com/nimajalali/go-force/force.SObject>, data = 0xc4200188f0}
err = {tab = 0x699eb7, data = 0xc}
(gdb) info locals
value·3.len = 842350821952
uri.len = 0
v·1 = 0xc4200fdd50
value·3.ptr = 0x410b18 <runtime.newobject+56> "H\213D$\030H\211D$8H\213l$ H\203\304(\303\350\217\"\004"
uri.ptr = 0xb0 <error: Cannot access memory at address 0xb0>
(gdb)

I am quite happy of course that there will be no object with ID "Your-Object-ID"; and maybe the credentials I supplied are invalid (although they seem OK, e.g. if I alter the password I get an authentication error)

But either way, I don't think go-force should panic in this situation.

@candlerb
Copy link
Author

Maybe duplicate of #14 ?

@candlerb
Copy link
Author

Yes I think this is a duplicate; the problem goes away if I change to some well-known object type like

func (t *SomeCustomSObject) ApiName() string {
        return "Account"
}

and now I get a sensible error:

force.ApiError{Fields:[]string(nil), Message:"Provided external ID field does not exist or is not accessible: Your-Object-ID", ErrorCode:"NOT_FOUND", ErrorName:"", ErrorDescription:""}

@nimajalali
Copy link
Owner

@candlerb Closing since duplicate of #14

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