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

database/sql: segmentation violation #18719

Closed
kardianos opened this issue Jan 19, 2017 · 5 comments
Closed

database/sql: segmentation violation #18719

kardianos opened this issue Jan 19, 2017 · 5 comments
Assignees
Milestone

Comments

@kardianos
Copy link
Contributor

@kardianos kardianos commented Jan 19, 2017

from builder log: https://build.golang.org/log/2c3b36d6c05318edc47728998463214689d2f2e2

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

goroutine 318 [running]:
database/sql.ctxDriverPrepare(0x6f3300, 0xc420202720, 0x0, 0x0, 0xc4201f86e0, 0x1d, 0x0, 0x0, 0x0, 0x0)
	/tmp/workdir/go/src/database/sql/ctxutil.go:17 +0x1c6
database/sql.(*DB).queryConn.func2()
	/tmp/workdir/go/src/database/sql/sql.go:1263 +0xb9
database/sql.withLock(0x6f2000, 0xc4200facb0, 0xc4203b7d98)
	/tmp/workdir/go/src/database/sql/sql.go:2441 +0x67
database/sql.(*DB).queryConn(0xc42023d970, 0x6f3300, 0xc420202720, 0xc4200facb0, 0x639fb0, 0xc4201f86e0, 0x1d, 0x0, 0x0, 0x0, ...)
	/tmp/workdir/go/src/database/sql/sql.go:1264 +0x683
database/sql.(*Tx).QueryContext(0xc4202027e0, 0x6f3300, 0xc420202720, 0xc4201f86e0, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/tmp/workdir/go/src/database/sql/sql.go:1669 +0x176
database/sql.TestIssue18429.func1(0xc420386e80, 0xc420394b30, 0x6f32c0, 0xc42009ad68, 0xc42023d970)
	/tmp/workdir/go/src/database/sql/sql_test.go:2645 +0x253
created by database/sql.TestIssue18429
	/tmp/workdir/go/src/database/sql/sql_test.go:2652 +0x1c9
FAIL	database/sql	0.160s

Is this a runtime issue or is the driver.Conn actually nil?

@kardianos kardianos self-assigned this Jan 19, 2017
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jan 19, 2017

@kardianos, anything suspicious or racy in the test?

Otherwise, cc @aclements @randall77 @cherrymui.

@bradfitz bradfitz added this to the Go1.8Maybe milestone Jan 19, 2017
@kardianos
Copy link
Contributor Author

@kardianos kardianos commented Jan 19, 2017

TestIssue18429 was designed to test the race condition in Tx.rollback. I don't think there is anything suspicious in the test itself.

After looking at this for a bit, I think this may be an issue with database/sql, not runtime. If driverConn.finalClose is called while DB.queryConn is running this may happen. We are correctly guarding data changes with a mutex, but not checking for a nil dc.ci in that lock. This is probably possible after any time currently if a context is canceled. I'll look into this further.

@kardianos
Copy link
Contributor Author

@kardianos kardianos commented Jan 19, 2017

I'm able to reproduce this issue on my box with a modified TestIssue18429 function. Not a runtime issue.

@josharian josharian changed the title databse/sql: segmentation violation database/sql: segmentation violation Jan 19, 2017
@kardianos
Copy link
Contributor Author

@kardianos kardianos commented Jan 23, 2017

I'm not sure why gobot didn't post it, but this should be resolved with https://go-review.googlesource.com/c/35550/

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 23, 2017

CL https://golang.org/cl/35550 mentions this issue.

@gopherbot gopherbot closed this in 2b283ce Jan 26, 2017
@golang golang locked and limited conversation to collaborators Jan 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.