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
Passing gzip.NewReader to s3manager.UploadInput causes SIGSEGV #3130
Comments
Hi @Integralist, thanks for reaching out to us. This looks like a duplicate of #3124, the code snippet isn't exactly the same but it still contains the variable scoping issue where I was able to successfully pass a f, err := os.Open("zipped.txt.gz")
if err != nil {
fmt.Printf("Error reading file: %v\n", err)
}
defer f.Close()
reader, err := gzip.NewReader(f)
if err != nil {
fmt.Printf("Error unzipping file: %v\n", err)
}
defer reader.Close()
input := &s3manager.UploadInput{
Bucket: aws.String("alex-sdk"),
Key: aws.String("go/3130/unzipped.txt"),
Body: reader,
}
resp, err := svc.Upload(input)
if err != nil {
fmt.Printf("Error uploading object: %v\n", err)
} else {
fmt.Printf("Object successfully uploaded to %v\n", resp.Location)
}
|
@diehlaws oh god I hope it's not the same issue as before 🤦♂️ I'll check this in the morning when I'm at my laptop. Thanks for the details (and patience!) |
In Go 1.12 vet included a You can either run vet with Note, make sure to run this outside of your Go module's directory tree because it will add addition entries to your go.mod, that aren't really needed. go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
go vet -vettool=$(which shadow) The steller` library had a neat way of installing tools like this on demand without modifing the project's go.mod. command -v shadow >/dev/null 2>&1 || (
dir=$(mktemp -d)
pushd $dir
go mod init tool
go get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
popd
)
shadow ./... |
Going to close this issue, as the problem with gzip.NewReader did appear to be related to a variable scope bug (my apologies for not catching that, especially considering my previous issue was exactly the same cause. your patience was appreciated ❤️) It seems there are still issues with using s3.manager.Upload with a httputil.ReverseProxy but it's a hard one to nail down because the stdlib proxy code provided by Go swallows the errors that are causing our application to panic (and as some requests work and some don't it's inconsistent behaviour which again means there's some form of race condition involved with data access or creation ...maybe 🤷♂ ) 😒 Any way, thanks for everyone's time, and @jasdel for the info re: the |
Please fill out the sections below to help us address your issue.
Version of AWS SDK for Go?
Version of Go (
go version
)?What issue did you see?
Trying to upload gzip compressed
http.Response#Body
to S3 would cause the content to be stored compressed, but we want to store the decompressed content instead.To work around that we attempt to wrap the
io.ReadCloser
of the response body ingzip.NewReader
which caused the following panic...Steps to reproduce
The following code demonstrates how we're reading the http response body...
We then pass the result of
readBody
tos3manager.UploadInput#Body
field.The text was updated successfully, but these errors were encountered: