go build -race problem with sqlite3

332 views
Skip to first unread message

varding

unread,
Oct 16, 2014, 10:58:22 AM10/16/14
to golan...@googlegroups.com
I build the code with the -race flag on window 7 x64 ,when I run it ,windows popup a dialog indicate that the exe is stopped,and there is no other information display in the console

if I build the code without -race flag,ererything is fine.

go: is 1.3.3 x64 

code shows as below:

package main

import (
"database/sql"
"fmt"
)

func main() {
db, err := sql.Open("sqlite3", "./test.db")
if err != nil {
fmt.Println("err%+v", err)
return
}
defer db.Close()

err = db.Ping()
if err != nil {
panic(err.Error())
}
fmt.Println("ok")
}

Dmitry Vyukov

unread,
Oct 16, 2014, 11:03:24 AM10/16/14
to varding, golang-nuts
Does other Go programs work with -race?

brainman

unread,
Oct 16, 2014, 6:55:33 PM10/16/14
to golan...@googlegroups.com
On Friday, 17 October 2014 01:58:22 UTC+11, varding wrote:
> ... when I run it ,windows popup a dialog indicate that the exe is stopped,and there is no other information display in the console

There were improvements made in Go runtime on "information display in the console" front recently. If you do your exercise on the tip, you will get stack trace instead. Like that:

C:\go\path\src\t>foo.exe
Exception 0xc0000005 0x8 0x6c3180 0x6c3180
PC=0x6c3180
signal arrived during cgo execution

        c:/go/path/src/github.com/mattn/go-sqlite3/sqlite3.go:264 +0x238
database/sql.(*DB).conn(0xc08204e000, 0x401217, 0x0, 0x0)
        c:/go/root/src/database/sql/sql.go:659 +0x7df
database/sql.(*DB).Ping(0xc08204e000, 0x0, 0x0)
        c:/go/root/src/database/sql/sql.go:457 +0x4f
main.main()
        C:/go/path/src/t/foo.go:17 +0x230

goroutine 2 [runnable]:
runtime.forcegchelper()
        c:/go/root/src/runtime/proc.go:90
runtime.goexit()
        c:/go/root/src/runtime/proc.c:1651

goroutine 3 [runnable]:
runtime.bgsweep()
        c:/go/root/src/runtime/mgc0.go:66
runtime.goexit()
        c:/go/root/src/runtime/proc.c:1651

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        c:/go/root/src/runtime/proc.c:1651

goroutine 4 [runnable]:
runtime.runfinq()
        c:/go/root/src/runtime/malloc.go:705
runtime.goexit()
        c:/go/root/src/runtime/proc.c:1651

goroutine 5 [runnable]:
database/sql.(*DB).connectionOpener(0xc08204e000)
        c:/go/root/src/database/sql/sql.go:583
created by database/sql.Open
        c:/go/root/src/database/sql/sql.go:447 +0x41a
rax     0x0
rbx     0x7
rcx     0x6ce4c0
rdx     0x6ce4c0
rdi     0x6ce4f0
rsi     0x6d2ec0
rbp     0x6ce7c0
rsp     0x22fd48
r8      0x2
r9      0x84
r10     0x42
r11     0x1330158
r12     0xc08201faf0
r13     0x1084d60
r14     0xc082016000
r15     0xc082008100
rip     0x6c3180
rflags  0x10246
cs      0x33
fs      0x53
gs      0x2b

I hope it helps.

Alex

varding

unread,
Oct 16, 2014, 9:47:58 PM10/16/14
to golang-nuts
Before I add the sqlite3 package to my project,everything is fine and go build -race works well too. But after I add the sqlite3 ,the exe which build by -race flag can't run correctly
So I start a new project with only sqlite3 package,the exe build with -race flag also run uncorrectly.The new project code is post in the email

varding

unread,
Oct 16, 2014, 10:02:55 PM10/16/14
to brainman, golang-nuts
内嵌图片 2

This is the dialog popup when I run the exe build the -race flag ,no more panic message display
The popup show in Chinese ,I translate it into English in red 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

varding

unread,
Oct 16, 2014, 10:11:56 PM10/16/14
to brainman, golang-nuts


the image is missing ,I send the email again

This is the dialog popup when I run the exe build the -race flag ,no more panic message display
The popup show in Chinese ,I translate it into English in red 
2014-10-17 6:55 GMT+08:00 brainman <alex.b...@gmail.com>:

--

brainman

unread,
Oct 16, 2014, 10:19:18 PM10/16/14
to golan...@googlegroups.com, alex.b...@gmail.com
I have created new issue https://code.google.com/p/go/issues/detail?id=8948 to investigate it properly.

Alex

varding

unread,
Oct 16, 2014, 10:32:40 PM10/16/14
to brainman, golang-nuts
thx

2014-10-17 10:19 GMT+08:00 brainman <alex.b...@gmail.com>:
I have created new issue https://code.google.com/p/go/issues/detail?id=8948 to investigate it properly.

Alex

--

mattn

unread,
Dec 2, 2014, 10:14:21 PM12/2/14
to golan...@googlegroups.com, alex.b...@gmail.com
Hmm, I can't reproduce this.

brainman

unread,
Dec 5, 2014, 12:56:53 AM12/5/14
to golan...@googlegroups.com, alex.b...@gmail.com
On Wednesday, 3 December 2014 14:14:21 UTC+11, mattn wrote:
> Hmm, I can't reproduce this.

Here is how I do it:

C:\go\path\src\issue8949>gcc --version
gcc (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\go\path\src\issue8949>hg -R %GOROOT% id
8d42099cdc23

C:\go\path\src\issue8949>type main.go
package main

import (
        "database/sql"
        "fmt"
)

func main() {
        db, err := sql.Open("sqlite3", "./test.db")
        if err != nil {
                fmt.Println("err%+v", err)
                return
        }
        defer db.Close()

        err = db.Ping()
        if err != nil {
                panic(err.Error())
        }
        fmt.Println("ok")
}
C:\go\path\src\issue8949>go run --race main.go
Exception 0xc0000005 0x8 0x6c4180 0x6c4180
PC=0x6c4180
signal arrived during cgo execution

        c:/go/path/src/github.com/mattn/go-sqlite3/sqlite3.go:267 +0x238
database/sql.(*DB).conn(0xc082036000, 0x401217, 0x0, 0x0)
        c:/go/root/src/database/sql/sql.go:664 +0x7df
database/sql.(*DB).Ping(0xc082036000, 0x0, 0x0)
        c:/go/root/src/database/sql/sql.go:462 +0x4f
main.main()
        C:/go/path/src/issue8949/main.go:17 +0x230

goroutine 2 [runnable]:
runtime.forcegchelper()
        c:/go/root/src/runtime/proc.go:90
runtime.goexit()
        c:/go/root/src/runtime/asm_amd64.s:2232 +0x1

goroutine 3 [runnable]:
runtime.bgsweep()
        c:/go/root/src/runtime/mgc0.go:82
runtime.goexit()
        c:/go/root/src/runtime/asm_amd64.s:2232 +0x1

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        c:/go/root/src/runtime/asm_amd64.s:2232 +0x1

goroutine 4 [runnable]:
runtime.runfinq()
        c:/go/root/src/runtime/malloc.go:712
runtime.goexit()
        c:/go/root/src/runtime/asm_amd64.s:2232 +0x1

goroutine 5 [runnable]:
database/sql.(*DB).connectionOpener(0xc082036000)
        c:/go/root/src/database/sql/sql.go:588
created by database/sql.Open
        c:/go/root/src/database/sql/sql.go:452 +0x41a
rax     0x0
rbx     0x7
rcx     0x6cf4c0
rdx     0x6cf4c0
rdi     0x6cf4f0
rsi     0x6d3f40
rbp     0x6cf7c0
rsp     0x22fd48
r8      0x2
r9      0x84
r10     0x42
r11     0x1160158
r12     0xc08201fae0
r13     0x1085e20
r14     0xc082016000
r15     0xc082008100
rip     0x6c4180
rflags  0x10246
cs      0x33
fs      0x53
gs      0x2b
exit status 2

C:\go\path\src\issue8949>

Alex
Reply all
Reply to author
Forward
0 new messages