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

Setting Broadcaster specific price segfault #2819

Closed
stronk-dev opened this issue Jul 1, 2023 · 2 comments · Fixed by #2820
Closed

Setting Broadcaster specific price segfault #2819

stronk-dev opened this issue Jul 1, 2023 · 2 comments · Fixed by #2820
Labels
status: triage this issue has not been evaluated yet

Comments

@stronk-dev
Copy link
Contributor

stronk-dev commented Jul 1, 2023

It works well in general, but when specifying 3 or more B's using CMD flags the program segfaults. This is caused due to an error being thrown in the ReadFromFile function, where os.Stat(s) returns an error which was not being covered by os.IsNotExist(err). After that info.IsDir() is called but info is undefined at that point

prices, _ := common.ReadFromFile(broadcasterPrices)

func ReadFromFile(s string) (string, error) {
info, err := os.Stat(s)
if os.IsNotExist(err) {
// If the supplied string is not a path to a file,
// assume it is the pass and return it
return s, nil
}
if info.IsDir() {

Entire segfault:

I0701 09:42:34.148159       1 db.go:458] Closing DB
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1a087b2]
goroutine 26 [running]:
github.com/livepeer/go-livepeer/common.ReadFromFile({0x7ffc84ab8acc, 0x131})
	/common/readfromfile.go:19 +0x72
github.com/livepeer/go-livepeer/cmd/livepeer/starter.getBroadcasterPrices({0x7ffc84ab8acc, 0x131})
	/cmd/livepeer/starter/starter.go:1444 +0x49
github.com/livepeer/go-livepeer/cmd/livepeer/starter.StartLivepeer({_, _}, {0xc00052e2f0, 0xc00052e300, 0xc00052e310, 0xc00052e320, 0xc00052e330, 0xc00052e340, 0xc00052e350, 0xc00052e410, ...})
	/cmd/livepeer/starter/starter.go:766 +0x3fb3
main.main.func1()
	/cmd/livepeer/livepeer.go:97 +0x58
created by main.main
	/cmd/livepeer/livepeer.go:96 +0xca5

Proposed solution is to return the string as-is if the ReadFromFile errors

Edit: this issue probably only occurs when using CMD flags to

@ad-astra-video
Copy link
Collaborator

ad-astra-video commented Jul 3, 2023

Just curious, what is the input string length max? Also, the max length is the file path?

@stronk-dev
Copy link
Contributor Author

stronk-dev commented Jul 3, 2023

Just curious, what is the input string length max?

Not sure, somewhere between specifying 2 and 3 broadcaster prices :p
OS.Stat returns an error after some point where the input string is too long to be a file path/directory. A nice edge case which wasn't being checked for or covered by unit tests

Edit: basically what happened is os.Stat(s) returns an error which was not being covered by os.IsNotExist(err). After that info.IsDir() is called but info is undefined at that point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage this issue has not been evaluated yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants