[security] golang Firestore SIGSEGV

64 views
Skip to first unread message

David

unread,
Feb 27, 2025, 12:22:35 PMFeb 27
to golang-nuts
_______________________________
# go run sigsegv.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa68a44]

goroutine 1 [running]:
cloud.google.com/go/firestore.(*Client).Close(...)
/root/go/pkg/mod/cloud.google.com/go/fire...@v1.18.0/client.go:138
main.main()
/var/www/html/crm/sigsegv.go:25 +0x104
exit status 2

___________________________________
#cat sigsegv.go
package main

import (

  "fmt"
  "context"
  "google.golang.org/api/option"
  "cloud.google.com/go/firestore"

)

func main() {

ctx := context.Background()
opt := option.WithCredentialsFile("MISSING_FILENAME")
client, err2 := firestore.NewClient(ctx, "MYPROJECT", opt)

if err2 != nil {
  fmt.Errorf("error initializing app: %v", err2)

} else {
fmt.Print("auth OK.\n")
}

client.Close()
}
________________________________________
# cat go.mod
module sigsegv

go 1.24.0

require (
cloud.google.com/go/firestore v1.18.0
google.golang.org/api v0.223.0
)

require (
cloud.google.com/go v0.117.0 // indirect
cloud.google.com/go/auth v0.15.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/longrunning v0.6.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/oauth2 v0.26.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.10.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
)

Ian Lance Taylor

unread,
Feb 27, 2025, 12:33:00 PMFeb 27
to David, golang-nuts
On Thu, Feb 27, 2025 at 9:22 AM David <dav.se...@gmail.com> wrote:
>
> _______________________________
> # go run sigsegv.go
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa68a44]
>
> goroutine 1 [running]:
> cloud.google.com/go/firestore.(*Client).Close(...)
> /root/go/pkg/mod/cloud.google.com/go/fire...@v1.18.0/client.go:138
> main.main()
> /var/www/html/crm/sigsegv.go:25 +0x104
> exit status 2

Are you asking a question? This is what I would expect from your program.

I note that if err2 != nil, you call fmt.Errorf, which just returns an
error value. Perhaps you mean fmt.Printf. I also note that you call
client.Close even if err2 != nil, which is why you get the SIGSEGV.

Ian
Reply all
Reply to author
Forward
0 new messages