mods icon indicating copy to clipboard operation
mods copied to clipboard

panic: runtime error: invalid memory address or nil pointer dereference on OpenBSD

Open huhndev opened this issue 1 year ago • 7 comments

Moin!

I just build mods on OpenBSD -current and got the following panic when trying to run mods. Reproducable with v1.0.0, v1.1.0 and the latest commits from main. v0.2.0 runs fine.

If I can provide any further information, please let me know.

$ mods
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf8db5c]

goroutine 1 [running]:
modernc.org/libc.(*TLS).setErrno(0x17533e0?, {0x245660?, 0x58f260?})
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/etc.go:189 +0xdc
modernc.org/libc.Xmalloc(0x2decc0?, 0x598868?)
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/mem.go:34 +0xc5
modernc.org/libc.init()
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/libc_openbsd.go:49 +0x1db

huhndev avatar Jan 09 '24 15:01 huhndev

seems to be an issue with modernc.org/libc: https://gitlab.com/cznic/libc/-/blob/v1.24.1/libc_openbsd.go?ref_type=tags#L49

I'll update modernc.org/sqlite (which depends on modernc.org/libc) and see if it changes anything, but by the looks of it it doesn't 🤔

If you can, please try go install github.com/charmbracelet/mods@libc and let me know how it goes. 🙏

caarlos0 avatar Jan 10 '24 01:01 caarlos0

$ go build
go: downloading modernc.org/sqlite v1.28.0
go: downloading modernc.org/libc v1.29.0
go: downloading modernc.org/mathutil v1.6.0
go: downloading modernc.org/memory v1.7.2
# github.com/charmbracelet/mods
./main.go:373:11: undefined: newUserError

$ go install github.com/charmbracelet/mods@libc
go: downloading github.com/charmbracelet/mods v1.1.1-0.20240110012018-c44309a87942
# github.com/charmbracelet/mods
/home/jhuhn/go/pkg/mod/github.com/charmbracelet/[email protected]/main.go:373:11: undefined: newUserError

Hmm, now it doesn't even build.

huhndev avatar Jan 10 '24 08:01 huhndev

oops, that's on me, fixing

caarlos0 avatar Jan 10 '24 11:01 caarlos0

fixed

caarlos0 avatar Jan 10 '24 11:01 caarlos0

Thank you for responding so quickly!

Unfortunately, it's the same panic again.

$ mods
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xfabebc]

goroutine 1 [running]:
modernc.org/libc.(*TLS).setErrno(0x178f640?, {0x246c20?, 0x59c3e8?})
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/etc.go:190 +0xdc
modernc.org/libc.Xmalloc(0x2e2620?, 0x5a5b48?)
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/mem.go:34 +0xc5
modernc.org/libc.init()
        /home/jhuhn/go/pkg/mod/modernc.org/[email protected]/libc_openbsd.go:49 +0x1db

huhndev avatar Jan 10 '24 11:01 huhndev

Seems to be related to https://gitlab.com/cznic/libc/-/issues/34

huhndev avatar Jan 10 '24 11:01 huhndev

yes, that seems to be it :|

will keep the issue open and update once they fix it upstream

caarlos0 avatar Jan 10 '24 12:01 caarlos0

I've reworked the necessary logic for modernc/libc on openbsd, It should also fix modernc/sqlite. Please update dependencies and try now.

Discussion at https://gitlab.com/cznic/libc/-/issues/34

cloudkucooland avatar May 29 '24 19:05 cloudkucooland

thanks @cloudkucooland! I just updated mods main to use it.

@huhndev could you test it on main again?

caarlos0 avatar Jun 03 '24 12:06 caarlos0

Moin!

mods builds and runs fine with your latest fix on OpenBSD -current.

Unfortunately, I no longer have an OpenAI API key, which is why I can only test up to the error message that I am missing the API key.

Thanks, @cloudkucooland and @caarlos0!

huhndev avatar Jun 03 '24 13:06 huhndev

@huhndev thank you for trying it! 🙏

caarlos0 avatar Jun 03 '24 13:06 caarlos0