Skip to content

Go 1.24 compatibility #227

@ncruces

Description

@ncruces

Discussed in #226

Originally posted by olivier-m February 13, 2025
Hi,

I've migrated Readeck (https://codeberg.org/readeck/readeck) from mattn driver to yours and so far, so good. Thanks for your work, I really enjoy not needing CGO anymore :)

Out of curiosity, I compiled the project with Go 1.24.0 and it panics with an "out of bounds memory access". Here's the message:

panic: wasm error: out of bounds memory access
	wasm stack trace:
		sqlite3.wasm.sqlite3BtreeCreateTable(i32,i32,i32) i32
		sqlite3.wasm.sqlite3VdbeExec(i32) i32
		sqlite3.wasm.sqlite3_step(i32) i32
		sqlite3.wasm.sqlite3_exec(i32,i32,i32,i32,i32) i32 [recovered]
	panic: wasm error: out of bounds memory access
	wasm stack trace:
		sqlite3.wasm.sqlite3BtreeCreateTable(i32,i32,i32) i32
		sqlite3.wasm.sqlite3VdbeExec(i32) i32
		sqlite3.wasm.sqlite3_step(i32) i32
		sqlite3.wasm.sqlite3_exec(i32,i32,i32,i32,i32) i32

goroutine 1 [running]:
github.com/doug-martin/goqu/v9.(*TxDatabase).Wrap.func1()
	github.com/doug-martin/goqu/[email protected]/database.go:635 +0xdd
panic({0x159e1e0?, 0xc003353a80?})
	runtime/panic.go:787 +0x132
github.com/ncruces/go-sqlite3.(*sqlite).call(0xc0031f8388, {0x17a463d, 0xc?}, {0xc002297090?, 0xc0002970b8?, 0x4161df?})
	github.com/ncruces/[email protected]/sqlite.go:189 +0x1a7
github.com/ncruces/go-sqlite3.(*Conn).Exec(0xc0009d02a0, {0xc003692800, 0x15a9})
	github.com/ncruces/[email protected]/conn.go:186 +0x106
github.com/ncruces/go-sqlite3/driver.(*conn).ExecContext(0xc000859680, {0x2933d70?, 0x37e99c0?}, {0xc003692800, 0x15a9}, {0x37e99c0?, 0xc001d5fb30?, 0xc000796400?})
	github.com/ncruces/[email protected]/driver/driver.go:405 +0x13f
database/sql.ctxDriverExec({0x2933d70?, 0x37e99c0?}, {0x7aba544a32d8?, 0xc000859680?}, {0x0?, 0x0?}, {0xc003692800?, 0xc0022972c0?}, {0x37e99c0, 0x0, ...})
	database/sql/ctxutil.go:31 +0xd7
database/sql.(*DB).execDC.func2()
	database/sql/sql.go:1713 +0x159
database/sql.withLock({0x292d2c8, 0xc00035f700}, 0xc002297490)
	database/sql/sql.go:3574 +0x71
database/sql.(*DB).execDC(0x7aba5449d2d8?, {0x2933d70, 0x37e99c0}, 0xc00035f700, 0xc003692800?, {0xc003692800, 0x15a9}, {0x0, 0x0, 0x0})
	database/sql/sql.go:1708 +0x216
database/sql.(*Tx).ExecContext(0xc00035f880, {0x2933d70, 0x37e99c0}, {0xc003692800, 0x15a9}, {0x0, 0x0, 0x0})
	database/sql/sql.go:2516 +0xad
github.com/doug-martin/goqu/v9.(*TxDatabase).ExecContext(0xc000a26230, {0x2933d70, 0x37e99c0}, {0xc003692800, 0x15a9}, {0x0, 0x0, 0x0})
	github.com/doug-martin/goqu/[email protected]/database.go:521 +0x8d
github.com/doug-martin/goqu/v9.(*TxDatabase).Exec(...)
	github.com/doug-martin/goqu/[email protected]/database.go:515
codeberg.org/readeck/readeck/internal/db.applyMigrations.func1()
	codeberg.org/readeck/readeck/internal/db/storage.go:179 +0x10f
github.com/doug-martin/goqu/v9.(*TxDatabase).Wrap(0xc000a26000?, 0x2963f20?)
	github.com/doug-martin/goqu/[email protected]/database.go:647 +0x56
codeberg.org/readeck/readeck/internal/db.applyMigrations()
	codeberg.org/readeck/readeck/internal/db/storage.go:169 +0xf6
codeberg.org/readeck/readeck/internal/db.Init(...)
	codeberg.org/readeck/readeck/internal/db/storage.go:140
codeberg.org/readeck/readeck/internal/app.InitApp()
	codeberg.org/readeck/readeck/internal/app/app.go:124 +0x405
codeberg.org/readeck/readeck/internal/app.appPreRun(0xc000022060)
	codeberg.org/readeck/readeck/internal/app/app.go:160 +0xde
codeberg.org/readeck/readeck/internal/app.runServer({0x179b168?, 0x7?}, {0xc000134090, 0x0, 0x0})
	codeberg.org/readeck/readeck/internal/app/serve.go:72 +0xf7
github.com/cristalhq/acmd.(*Runner).Run(0xc0005c0000)
	github.com/cristalhq/[email protected]/acmd.go:300 +0x107
codeberg.org/readeck/readeck/internal/app.Run()
	codeberg.org/readeck/readeck/internal/app/app.go:70 +0xe5
main.main()
	codeberg.org/readeck/readeck/main.go:16 +0x13

This was on first launch during schema creation. On an existing database, it fails (same error) with some specific requests but not all of them.

If you'd like to reproduce, you can compile with:
make setup && make generate && make build after changing the go value to 1.24 in go.mod. I don't know if that's an issue on your side, wazero or somewhere else. Let me know if I can perform more tests.

PS: the migration to WASM was done in this branch: https://codeberg.org/readeck/readeck/pulls/411/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions