Closed ivanovaleksey closed 9 months ago
Thanks for the report. Could you please check with the latest v1.5.1 to see, if the segfault still exists?
Hi,Marcboeker, I encountered the same error. version is v1.5.6
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1000d38d6] goroutine 1 [running]: github.com/marcboeker/go-duckdb.(stmt).execute(0xc0000a00d8, {0x0, 0x0}, {0x0?, 0xc00005a900?, 0x1000cd525?}) /Users/samyang/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6/statement.go:209 +0x1d6 github.com/marcboeker/go-duckdb.(stmt).ExecContext(0xc000098100?, {0x0?, 0x0?}, {0x0?, 0x0?, 0x0?}) /Users/samyang/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6/statement.go:159 +0x47 github.com/marcboeker/go-duckdb.(conn).ExecContext(0xc000098100, {0x0, 0x0}, {0x10160fdea, 0xe}, {0x0, 0x0, 0x0}) /Users/samyang/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6/connection.go:62 +0x33d main.connection.func1({0x101639780, 0xc000098100}) /Users/samyang/GolandProjects/syncmaster/example/duckdb/main.go:161 +0xdc github.com/marcboeker/go-duckdb.(connector).Connect(0xc0000980e0, {0xc00005aba0, 0x100014eee}) /Users/samyang/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6/duckdb.go:100 +0x8a database/sql.(DB).conn(0xc00009e750, {0x101639c48, 0x101955c80}, 0x1) /usr/local/opt/go/libexec/src/database/sql/sql.go:1387 +0x717 database/sql.(DB).query(0x10194f868?, {0x101639c48, 0x101955c80}, {0x101614fd4, 0x25}, {0x0, 0x0, 0x0}, 0xc0?) /usr/local/opt/go/libexec/src/database/sql/sql.go:1721 +0x57 database/sql.(DB).QueryContext.func1(0x76?) /usr/local/opt/go/libexec/src/database/sql/sql.go:1704 +0x4f database/sql.(DB).retry(0x1026261c0?, 0xc00005adc0) /usr/local/opt/go/libexec/src/database/sql/sql.go:1538 +0x42 database/sql.(DB).QueryContext(0xc00009c360?, {0x101639c48?, 0x101955c80?}, {0x101614fd4?, 0x101639b38?}, {0x0?, 0x1000d7ab9?, 0xc00009e750?}) /usr/local/opt/go/libexec/src/database/sql/sql.go:1703 +0xc5 database/sql.(DB).QueryRowContext(...) /usr/local/opt/go/libexec/src/database/sql/sql.go:1804 database/sql.(*DB).QueryRow(0x10160f0cb?, {0x101614fd4?, 0xc00004a6d8?}, {0x0?, 0xc0000061a0?, 0xc00004a6f8?}) /usr/local/opt/go/libexec/src/database/sql/sql.go:1818 +0x45 main.main() /Users/samyang/GolandProjects/syncmaster/example/duckdb/main.go:36 +0x66 exit status 2
My Code:
connector, := duckdb.NewConnector(dsn, func(execer driver.ExecerContext) error { bootQueries := []string{ "INSTALL 'json'", "LOAD 'json'", } var ctx context.Context for , qry := range bootQueries { _, err := execer.ExecContext(ctx, qry, nil) log.Printf("%v", qry) if err != nil { return err } } return nil }) db := sql.OpenDB(connector) db.SetMaxOpenConns(100) return db
I was able to reproduce this. You can skip the connector and use the db, err := sql.Open("duckdb", "")
and then db.QueryContext()
until it's fixed. You manually have to install and load the JSON plugin using db.ExecContext("INSTALL 'json'; LOAD 'json';")
.
@imysm The problem lies in your code. You are providing a context variable which is not initialized with a proper context. See var ctx context.Context
which should be ctx := context.Background()
or provide context.Background()
directly.
for _, qry := range bootQueries {
_, err := execer.ExecContext(context.Background(), qry, nil)
log.Printf("%v", qry)
if err != nil {
return err
}
}
ehhh thank you ,this is my problem .
Hey!
Got a segmentation fault error recently. Running Go 1.20 and go-duckdb v1.4.1 Unfortunately I currently don't have a clear use case how to reproduce the error. It happened only once so far.
Please see the stack trace below. Is there any additional info that could help to spot the problem?