go-llvm / llgo

LLVM-based compiler for Go
Other
1.25k stars 81 forks source link

panic on import #226

Open rogpeppe opened 8 years ago

rogpeppe commented 8 years ago

I knew this was a ridiculous thing to try, but I tried it anyway...

% llgo.llgoi
(llgo) import "github.com/juju/juju/api"
panic: runtime error: string index out of bounds
:0 (0x7e2efc)
    ???: ???
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:174 (0x7e2e19)
:0 (0x7e2e72)
    ???: ???
:0 (0x7f947243b66d)
    ???: ???
:0 (0x7f947244f926)
    ???: ???
:0 (0x7f947243df52)
    ???: ???
:0 (0x7f946c86d8ca)
    ???: ???
:0 (0x7f946c86d7b4)
    ???: ???
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:180 (0x7e29a0)
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:458 (0x7e1cb0)
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:441 (0x7e1737)
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:487 (0x7e5230)
/tmp/gopath683283970/src/llvm.org/llgo/cmd/llgoi/llgoi.go:584 (0x7e68cc)
:0 (0x7f947245277d)
    ???: ???
:0 (0x7f9472455408)
    ???: ???
:0 (0x7f9471488590)
    ???: ???
axw commented 8 years ago

Heh, been there :)

The panic is due to some code in the juju/errors package, where we call runtime.Caller. The result is invalid (no path is returned), but no error is returned either. I believe the issue is to do with back tracing in the gofrontend runtime, which assumes that all code lives in the main executable. It would need to be updated to search dynamic libraries also.