Skip to content

x/website: sql.Rows example panics. #40664

@feidtmb

Description

@feidtmb

What did you do?

Ran the example under the sql.Rows type at https://golang.org/pkg/database/sql/#Rows.Scan.

What did you expect to see?

Logged output from the call:

log.Printf("%s are %d years old", strings.Join(names, ", "), age)
  • (I don't know what's in the database so not sure what exactly the output should be.)

What did you see instead?

A panic:

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

goroutine 1 [running]:
database/sql.(*DB).conn(0x0, 0x0, 0x0, 0x203001, 0xc00006ae38, 0x203000, 0x203000)
	/usr/local/go-faketime/src/database/sql/sql.go:1134 +0x41
database/sql.(*DB).query(0x0, 0x0, 0x0, 0x4f2cf0, 0x22, 0xc00006af38, 0x1, 0x1, 0xc000010201, 0x5aeb00, ...)
	/usr/local/go-faketime/src/database/sql/sql.go:1552 +0x66
database/sql.(*DB).QueryContext(0x0, 0x0, 0x0, 0x4f2cf0, 0x22, 0xc00006af38, 0x1, 0x1, 0xc00006af18, 0x4b474a, ...)
	/usr/local/go-faketime/src/database/sql/sql.go:1534 +0xd1
main.main()
	/tmp/sandbox184082418/prog.go:17 +0xcf

Program exited.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions