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

Panics when building with -ldflags="-linkmode internal" #272

Closed
ToadKing opened this issue Feb 18, 2016 · 0 comments
Closed

Panics when building with -ldflags="-linkmode internal" #272

ToadKing opened this issue Feb 18, 2016 · 0 comments

Comments

@ToadKing
Copy link

go-sqlite3 panics inside C code when you link your go program with the internal linkmode.

  • Go version: 1.6
  • OS: Windows 10 64-bit
  • GCC: TDM-GCC 5.1.0-3

Test program:

package main

import (
    "database/sql"
    _ "github.com/mattn/go-sqlite3"
    "os"
)

func main() {
    // reproducable on a blank db
    os.Remove("test.sqlite")

    conn, err := sql.Open("sqlite3", "test.sqlite")
    if err != nil {
        panic(err)
    }

    stmt, err := conn.Prepare("")
    if err != nil {
        panic(err)
    }

    defer stmt.Close()
    _, err = stmt.Exec()

    if err != nil {
        panic(err)
    }
}

Build command: go build -ldflags="-linkmode internal" test

Output:

fatal error: unexpected signal during runtime execution
[signal 0xc0000005 code=0x0 addr=0x30 pc=0x505d50]

runtime stack:
invalid spdelta sqlite3_last_insert_rowid 0x505d50 0x505d50 0x0 -1
runtime.throw(0x6398c0, 0x2a)
        C:/Go/src/runtime/panic.go:530 +0x97
runtime.sigpanic()
        C:/Go/src/runtime/signal_windows.go:155 +0x68
invalid spdelta sqlite3_last_insert_rowid 0x505d50 0x505d50 0x0 -1
sqlite3_last_insert_rowid()
        ?:0

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x500490, 0xc082031c20, 0x100000000000000)
        C:/Go/src/runtime/cgocall.go:123 +0x117 fp=0xc082031be8 sp=0xc082031bb8
github.com/mattn/go-sqlite3._Cfunc__sqlite3_step(0x0, 0xc082002338, 0xc082002370, 0x0)
        github.com/mattn/go-sqlite3/_obj/_cgo_gotypes.go:249 +0x48 fp=0xc082031c20 sp=0xc082031be8
github.com/mattn/go-sqlite3.(*SQLiteStmt).Exec(0xc08200a2d0, 0x712cf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/repos/delve-test/src/github.com/mattn/go-sqlite3/sqlite3.go:860 +0x28b fp=0xc082031cd8 sp=0xc082031c20
database/sql.resultFromStatement(0xa442b0, 0xc082032070, 0xa44248, 0xc08200a2d0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Go/src/database/sql/sql.go:1502 +0x3de fp=0xc082031e08 sp=0xc082031cd8
database/sql.(*Stmt).Exec(0xc082066000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Go/src/database/sql/sql.go:1470 +0x2b5 fp=0xc082031ee0 sp=0xc082031e08
main.main()
        C:/repos/delve-test/src/test/main.go:24 +0x152 fp=0xc082031f40 sp=0xc082031ee0
runtime.main()
        C:/Go/src/runtime/proc.go:188 +0x27e fp=0xc082031f90 sp=0xc082031f40
runtime.goexit()
        C:/Go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc082031f98 sp=0xc082031f90

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        C:/Go/src/runtime/asm_amd64.s:1998 +0x1

goroutine 5 [chan receive]:
database/sql.(*DB).connectionOpener(0xc082058000)
        C:/Go/src/database/sql/sql.go:727 +0x4c
created by database/sql.Open
        C:/Go/src/database/sql/sql.go:493 +0x346
gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
@mattn mattn closed this as completed in c9394b1 May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant