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

Panicking while compiling a simple Go program #651

Open
BahaaBBM opened this issue Aug 3, 2024 · 9 comments
Open

Panicking while compiling a simple Go program #651

BahaaBBM opened this issue Aug 3, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@BahaaBBM
Copy link

BahaaBBM commented Aug 3, 2024

Hello, this is my first time using llgo. I'm encountering a panic when trying to compile a simple 'Hello, World' program.

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

goroutine 1 [running]:
github.com/goplus/llgo/ssa.(*aProgram).rtNamed(0xc00008a008, {0x82d90b, 0x5})
	/go/src/llgo/ssa/package.go:256 +0xb4
github.com/goplus/llgo/ssa.(*aProgram).rtType(0xc00008a008, {0x82d90b?, 0xc00b639f80?})
	/go/src/llgo/ssa/package.go:262 +0x1d
github.com/goplus/llgo/ssa.(*aProgram).rtIface(...)
	/go/src/llgo/ssa/package.go:274
github.com/goplus/llgo/ssa.(*aProgram).toType(0xc00008a008, {0x8b5620, 0xc000100a50})
	/go/src/llgo/ssa/type.go:373 +0xc93
github.com/goplus/llgo/ssa.(*aProgram).rawType(0xc00008a008, {0x8b5620, 0xc000100a50})
	/go/src/llgo/ssa/type.go:252 +0x65
github.com/goplus/llgo/ssa.(*aProgram).toNamed(0xc00008a008, 0xc000142070)
	/go/src/llgo/ssa/type.go:511 +0x17a
github.com/goplus/llgo/ssa.(*aProgram).toType(0xc00008a008, {0x8b5648, 0xc000142070})
	/go/src/llgo/ssa/type.go:382 +0x191
github.com/goplus/llgo/ssa.(*aProgram).rawType(0xc00008a008, {0x8b5648, 0xc000142070})
	/go/src/llgo/ssa/type.go:252 +0x65
github.com/goplus/llgo/ssa.(*aProgram).toLLVMTypes(0xc00008a008, 0xc005dffda0, 0x2)
	/go/src/llgo/ssa/type.go:447 +0x89
github.com/goplus/llgo/ssa.(*aProgram).toLLVMFunc(0xc00008a008, 0xc005e42200)
	/go/src/llgo/ssa/type.go:460 +0x4f
github.com/goplus/llgo/ssa.(*aProgram).FuncDecl(0xc00008a008, 0xc007e6b408?, 0xc00aa13af0?)
	/go/src/llgo/ssa/type_cvt.go:66 +0x65
github.com/goplus/llgo/ssa.(*aPackage).NewFuncEx(0xc0070407e0, {0xc00aa13af0, 0x9}, 0xc005e42200, 0x1, 0x0)
	/go/src/llgo/ssa/decl.go:191 +0x92
github.com/goplus/llgo/cl.(*context).compileFuncDecl(0xc005b52270, 0xc0070407e0, 0xc0094b0000)
	/go/src/llgo/cl/compile.go:229 +0x945
github.com/goplus/llgo/cl.processPkg(0xc005b52270, 0xc0070407e0, 0xc009297680)
	/go/src/llgo/cl/compile.go:871 +0x394
github.com/goplus/llgo/cl.NewPackageEx(0xc00008a008, 0xc00798dcb0, 0xc009297680, {0xc005af6360, 0x3, 0x3})
	/go/src/llgo/cl/compile.go:829 +0x614
github.com/goplus/llgo/internal/build.buildPkg(0xc007af8240, 0xc0091aba60, 0x0)
	/go/src/llgo/internal/build/build.go:490 +0x308
github.com/goplus/llgo/internal/build.buildAllPkgs(0xc007af8240, {0xc0075e9f50?, 0xc0000341c0?, 0x82d070?}, 0x0)
	/go/src/llgo/internal/build/build.go:327 +0x3f1
github.com/goplus/llgo/internal/build.Do({0xc000112230?, 0x82d0ab?, 0x2?}, 0xc007e6be08)
	/go/src/llgo/internal/build/build.go:195 +0xa91
github.com/goplus/llgo/cmd/internal/build.runCmd(0xc000142000?, {0xc000112230?, 0x0?, 0x0?})
	/go/src/llgo/cmd/internal/build/build.go:44 +0x9d
main.main()
	/go/src/llgo/cmd/llgo/llgo.go:90 +0x4b3

@xushiwei
Copy link
Member

xushiwei commented Aug 3, 2024

please print your go version?

go version

@xushiwei xushiwei added the bug Something isn't working label Aug 3, 2024
@BahaaBBM
Copy link
Author

BahaaBBM commented Aug 4, 2024

go1.22.5 linux/amd64

@aofei
Copy link
Member

aofei commented Aug 4, 2024

Please provide the output of:

  • llgo version (or simply tell us how it was installed, especially if it prints something like llgo (devel) linux/amd64)
  • go env
  • uname -a
  • cat /etc/os-release

@BahaaBBM
Copy link
Author

BahaaBBM commented Aug 4, 2024

llgo v0.9.4 linux/amd64

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/smart/.cache/go-build'
GOENV='/home/smart/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/smart/Go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/smart/Go/'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/smart/Programs/go/'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/smart/Programs/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3919813185=/tmp/go-build -gno-record-gcc-switches'

Linux smart-Latitude-E6400 5.15.0-117-generic #127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux


NAME="Linux Mint"
VERSION="21.2 (Victoria)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.2"
VERSION_ID="21.2"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=victoria
UBUNTU_CODENAME=jammy

@BahaaBBM
Copy link
Author

BahaaBBM commented Aug 4, 2024

Please provide the output of:

* `llgo version` (or simply tell us how it was installed, especially if it prints something like `llgo (devel) linux/amd64`)

* `go env`

* `uname -a`

* `cat /etc/os-release`

I tried to install it in both ways, using go install -v github.com/goplus/llgo/cmd/llgo@latest and downloading the binary release, both didn't work.

@xushiwei
Copy link
Member

xushiwei commented Aug 5, 2024

Do you add require github.com/goplus/llgo v0.9.4 in your go.mod file?

@BahaaBBM
Copy link
Author

BahaaBBM commented Aug 5, 2024

Do you add require github.com/goplus/llgo v0.9.4 in your go.mod file?

Thanks, I didn't know that I have to do that, I just tried it on a simple file llgo build main.go. But now I ran into another error:

ld.lld: error: undefined symbol: syscall.WaitStatus.TrapCause
>>> referenced by os
>>>               /tmp/8143fa2412f629088bf8c54fcae3e8558113ac1c841b81acd18731f59d7554fc-d-1a6e55.o:(os.(*ProcessState).String)
>>> referenced by os
>>>               /tmp/8143fa2412f629088bf8c54fcae3e8558113ac1c841b81acd18731f59d7554fc-d-1a6e55.o:(os.(*ProcessState).String)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@BahaaBBM
Copy link
Author

BahaaBBM commented Aug 5, 2024

I think the problem is related to the fmt package? Removing the fmt package resolved the issue.

@xushiwei
Copy link
Member

xushiwei commented Aug 6, 2024

Thanks, I didn't know that I have to do that, I just tried it on a simple file llgo build main.go.

Will do this automatically in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants