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 in go client when submission request fails / times out #29

Open
gregtws opened this issue Mar 13, 2023 · 1 comment
Open

Panic in go client when submission request fails / times out #29

gregtws opened this issue Mar 13, 2023 · 1 comment

Comments

@gregtws
Copy link

gregtws commented Mar 13, 2023

Observing a panic in the go client when it errors out during file submission.

When using the v1.0.0 go client function SubmitSampleFile to submit a file, the following error is returned to the caller:

triage: Post "https://private.tria.ge/api/v0/samples": dial tcp 51.15.123.173:443: i/o timeout

Then a panic occurs in sample.go:

Failed to submit file
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x666965]
goroutine 60344 [running]:
github.com/hatching/triage/go.(*Client).SubmitSampleFile.func1()
/go/pkg/mod/github.com/hatching/[email protected]/go/sample.go:108 +0xe5
created by github.com/hatching/triage/go.(*Client).SubmitSampleFile
/go/pkg/mod/github.com/hatching/[email protected]/go/sample.go:101 +0x3f2

The trace seems a bit confusing that it would fail on those lines (vs say in the defer or somewhere else). So probably needs a bit more digging to see whats going on and how to recover cleanly.

@gregtws
Copy link
Author

gregtws commented Dec 14, 2023

Seeing another spate of these. Based on the trace, I suspect its due to unchecked errors in the multipart calls, but I don't have a good way to consistently reproduce:

// samples.go
		jsonField, _ := mw.CreateFormField("_json")
		jsonField.Write(request) // jsonField can be nil

		fileField, _ := mw.CreateFormFile("file", filename)
		io.Copy(fileField, file) // fileField can be nil

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