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 dereference when calling PrepareToSend(..) #33

Closed
annygakh opened this issue Mar 18, 2018 · 2 comments
Closed

nil pointer dereference when calling PrepareToSend(..) #33

annygakh opened this issue Mar 18, 2018 · 2 comments

Comments

@annygakh
Copy link
Contributor

Code I am using:

package main

import (
	"github.com/DistributedClocks/GoVector/govec"
)

func main() {
	LoggerClient := govec.InitGoVectorMultipleExecutions("2", "test")
	LoggerClient.PrepareSend("Sending", "blabla")
}

Problem:
I get the following error

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

goroutine 1 [running]:
github.com/DistributedClocks/GoVector/govec.(*GoLog).PrepareSend(0xc420134100, 0x1393dde, 0x7, 0x1316880, 0x13d6600, 0x0, 0xc420125f70, 0x12de28e)
        /Users/annygakh/go/src/github.com/DistributedClocks/GoVector/govec/govec.go:507 +0x25d
main.main()
        /Users/annygakh/go/src/test-shiviz/test.go:12 +0x93
exit status 2

Possible fix:
It seems like there is missing initialization of private fields gv.encodingStrategy (and gv.decodingStrategy). The fields are initialized in InitGoVector, but not in InitGoVectorMultipleExecutions (which is what I am using). Attached is a proposed fix.

patch.diff.txt

@bestchai
Copy link
Member

Sigh, thanks for catching that.

Your fix seems fine. Does it get past the panic with your fix? (i.e., does it resolve the problem)

There is a SetEncoderDecoder function that can be used for initializing (though I don't see it being used..); maybe we should update existing code to use it?

@annygakh
Copy link
Contributor Author

Yes, the changes submitted in the above patch seemed to fix the problem, and the code got past the panic.

Furthermore, I have a bigger code example in which I actually use the result of PrepareSend(...) to pass over the network, followed by UnpackReceive(...) and the logs are generated correctly. I can attach the bigger code example here if you would like.

As per your suggestion, I created another patch, using SetEncoderDecoder in InitGoVector and InitGoVectorMultipleExecutions. However, I have not ran any internal tests that this repository provides with this change (I'm not sure how to).

patch.diff.txt

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