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

Cause panic on arm9 #108

Open
305236917 opened this issue Nov 15, 2023 · 3 comments
Open

Cause panic on arm9 #108

305236917 opened this issue Nov 15, 2023 · 3 comments

Comments

@305236917
Copy link

305236917 commented Nov 15, 2023

Question:

  1. I had no problem running it on Cortex-A7, but I had problems running it on arm9
  2. The CGO version works on arm9

Code:
package main

import (
"github.com/glebarez/sqlite"
"gorm.io/gorm"
)

type Product struct {
gorm.Model
Code string
Price uint
}

func main() {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
db.AutoMigrate(&Product{})
}

Build args:
GOARCH=arm GOOS=linux GOARM=5 go build .

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

goroutine 1 [running]:
modernc.org/sqlite/lib.Xsqlite3WhereBegin(0x2d025a0, 0xae5008b0, 0xad50b2b8, 0x0, 0xad50b0b8, 0xad507548, 0xad50b038, 0x0, 0x140)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:106300 +0xd20
modernc.org/sqlite/lib.Xsqlite3Select(0x2d025a0, 0xae5008b0, 0xad50b038, 0xae500f00)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:92009 +0x19fc
modernc.org/sqlite/lib.yy_reduce(0x2d025a0, 0xae5009f0, 0x54, 0x1, {0xad50b466, 0x0}, 0xae5008b0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:111851 +0x10d4
modernc.org/sqlite/lib.Xsqlite3Parser(0x2d025a0, 0xae5009f0, 0x1, {0xad50b466, 0x0})
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:113411 +0xb8
modernc.org/sqlite/lib.Xsqlite3RunParser(0x2d025a0, 0xae5008b0, 0xad50b438)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:114134 +0x32c
modernc.org/sqlite/lib.sqlite3Prepare(0x2d025a0, 0xad900018, 0xad50b438, 0xffffffff, 0x80, 0x0, 0xae500890, 0xae500894)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:85921 +0x338
modernc.org/sqlite/lib.sqlite3LockAndPrepare(0x2d025a0, 0xad900018, 0xad50b438, 0xffffffff, 0x80, 0x0, 0xae500890, 0xae500894)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:86004 +0x150
modernc.org/sqlite/lib.Xsqlite3_prepare_v2(...)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:86071
modernc.org/sqlite/lib.Xsqlite3_exec(0x2d025a0, 0xad900018, 0xad50b438, 0x48747c, 0xae500858, 0x0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:80623 +0x218
modernc.org/sqlite/lib.Xsqlite3InitOne(0x2d025a0, 0xad900018, 0x0, 0xae500054, 0x0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:85545 +0x850
modernc.org/sqlite/lib.Xsqlite3Init(0x2d025a0, 0xad900018, 0xae500054)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:85622 +0x70
modernc.org/sqlite/lib.Xsqlite3ReadSchema(0x2d025a0, 0xae500050)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:85649 +0x50
modernc.org/sqlite/lib.Xsqlite3LocateTable(0x2d025a0, 0xae500050, 0x0, 0xad50b738, 0x0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:68135 +0xa8
modernc.org/sqlite/lib.Xsqlite3LocateTableItem(0x2d025a0, 0xae500050, 0x0, 0xad50b8c0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:68192 +0x60
modernc.org/sqlite/lib.selectExpander(0x2d025a0, 0xae500790, 0xad50b4b8)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:90568 +0x330
modernc.org/sqlite/lib.Xsqlite3WalkSelect(0x2d025a0, 0xae500790, 0xad50b4b8)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:54992 +0x70
modernc.org/sqlite/lib.sqlite3SelectExpand(0x2d025a0, 0xae500050, 0xad50b4b8)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:90856 +0xf8
modernc.org/sqlite/lib.Xsqlite3SelectPrep(0x2d025a0, 0xae500050, 0xad50b4b8, 0x0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:90931 +0x50
modernc.org/sqlite/lib.Xsqlite3Select(0x2d025a0, 0xae500050, 0xad50b4b8, 0xae5006a0)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:91558 +0x1d4
modernc.org/sqlite/lib.yy_reduce(0x2d025a0, 0xae500190, 0x54, 0x1, {0xadb00550, 0x0}, 0xae500050)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:111851 +0x10d4
modernc.org/sqlite/lib.Xsqlite3Parser(0x2d025a0, 0xae500190, 0x1, {0xadb00550, 0x0})
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:113411 +0xb8
modernc.org/sqlite/lib.Xsqlite3RunParser(0x2d025a0, 0xae500050, 0xadb00510)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:114134 +0x32c
modernc.org/sqlite/lib.sqlite3Prepare(0x2d025a0, 0xad900018, 0xadb00510, 0xffffffff, 0x80, 0x0, 0xae300060, 0xae300068)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:85921 +0x338
modernc.org/sqlite/lib.sqlite3LockAndPrepare(0x2d025a0, 0xad900018, 0xadb00510, 0xffffffff, 0x80, 0x0, 0xae300060, 0xae300068)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:86004 +0x150
modernc.org/sqlite/lib.Xsqlite3_prepare_v2(...)
/Users/trevan/go/pkg/mod/modernc.org/[email protected]/lib/sqlite_linux_arm.go:86071
github.com/glebarez/go-sqlite.(*conn).prepareV2(0x2c8fde0, 0x2c7591c)
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/sqlite.go:1275 +0x17c
github.com/glebarez/go-sqlite.(*stmt).query(0x2d1c6b8, {0x4f24a0, 0x755d78}, {0x2d2c060, 0x1, 0x1})
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/sqlite.go:605 +0x134
github.com/glebarez/go-sqlite.(*conn).query(0x2c8fde0, {0x4f24a0, 0x755d78}, {0x2c39500, 0x40}, {0x2d2c060, 0x1, 0x1})
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/sqlite.go:1519 +0x100
github.com/glebarez/go-sqlite.(*conn).QueryContext(0x2c8fde0, {0x4f24a0, 0x755d78}, {0x2c39500, 0x40}, {0x2d2c060, 0x1, 0x1})
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/sqlite_go18.go:38 +0x54
database/sql.ctxDriverQuery({0x4f24a0, 0x755d78}, {0xae830d80, 0x2c8fde0}, {0x0, 0x0}, {0x2c39500, 0x40}, {0x2d2c060, 0x1, ...})
/usr/local/go/src/database/sql/ctxutil.go:48 +0x94
database/sql.(*DB).queryDC.func1()
/usr/local/go/src/database/sql/sql.go:1748 +0x178
database/sql.withLock({0x4f1fa8, 0x2d1a000}, 0x2c75b5c)
/usr/local/go/src/database/sql/sql.go:3502 +0x84
database/sql.(*DB).queryDC(0x2c76870, {0x4f24a0, 0x755d78}, {0x0, 0x0}, 0x2d1a000, 0x2d1c6b0, {0x2c39500, 0x40}, {0x2d1c678, ...})
/usr/local/go/src/database/sql/sql.go:1743 +0x174
database/sql.(*DB).query(0x2c76870, {0x4f24a0, 0x755d78}, {0x2c39500, 0x40}, {0x2d1c678, 0x1, 0x1}, 0x1)
/usr/local/go/src/database/sql/sql.go:1726 +0xe4
database/sql.(*DB).QueryContext.func1(0x1)
/usr/local/go/src/database/sql/sql.go:1704 +0x6c
database/sql.(*DB).retry(0x2c76870, 0x2c75c64)
/usr/local/go/src/database/sql/sql.go:1538 +0x78
database/sql.(*DB).QueryContext(0x2c76870, {0x4f24a0, 0x755d78}, {0x2c39500, 0x40}, {0x2d1c678, 0x1, 0x1})
/usr/local/go/src/database/sql/sql.go:1703 +0x9c
database/sql.(*DB).QueryRowContext(0x2c76870, {0x4f24a0, 0x755d78}, {0x2c39500, 0x40}, {0x2d1c678, 0x1, 0x1})
/usr/local/go/src/database/sql/sql.go:1804 +0x54
gorm.io/gorm/callbacks.RowQuery(0x2d1e9e0)
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/callbacks/row.go:18 +0x208
gorm.io/gorm.(*processor).Execute(0x2ce0b40, 0x2d1e9e0)
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/callbacks.go:130 +0x3ec
gorm.io/gorm.(*DB).Row(0x2d1e9e0)
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/finisher_api.go:502 +0x94
github.com/glebarez/sqlite.Migrator.HasTable.func1(0x2c6ab60)
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/migrator.go:32 +0x94
gorm.io/gorm/migrator.Migrator.RunWithValue({{0x1, 0x2d1e9c0, {0x4f2980, 0x2d2c048}}}, {0x42e9e8, 0x2d02640}, 0x2c75e34)
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/migrator/migrator.go:71 +0x144
github.com/glebarez/sqlite.Migrator.HasTable({{{0x1, 0x2d1e9c0, {0x4f2980, 0x2d2c048}}}}, {0x42e9e8, 0x2d02640})
/Users/trevan/go/pkg/mod/github.com/glebarez/[email protected]/migrator.go:31 +0x90
gorm.io/gorm/migrator.Migrator.AutoMigrate({{0x1, 0x2d1e5c0, {0x4f2980, 0x2cbdd88}}}, {0x2d1c350, 0x1, 0x1})
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/migrator/migrator.go:120 +0x198
gorm.io/gorm.(*DB).AutoMigrate(0x2c8fd40, {0x2d1c350, 0x1, 0x1})
/Users/trevan/go/pkg/mod/gorm.io/[email protected]/migrator.go:24 +0x48
main.main()
/Users/trevan/Code/VSCode/demo/dnptime/main.go:28 +0x130

@wang182
Copy link

wang182 commented Feb 20, 2024

The same issue, but on arm5,do you have a solution?

@wang182
Copy link

wang182 commented Feb 20, 2024

@glebarez

@305236917
Copy link
Author

The same issue, but on arm5,do you have a solution?

Nope, I used the CGO version instead of it.

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

2 participants