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

panic: unresolve external: runtime.writeBarrier #32

Closed
jimil749 opened this issue Jun 14, 2021 · 9 comments
Closed

panic: unresolve external: runtime.writeBarrier #32

jimil749 opened this issue Jun 14, 2021 · 9 comments
Labels
question Further information is requested

Comments

@jimil749
Copy link

I have following "plugin" code that I am trying to load using goloader: Link to code. It has a dependency on another package (link). On compiling the code, and loading using goloader (as explained in the example, link), it throws following error:

panic: unresolve external: runtime.writeBarrier

Any clue how to solve this?

@pkujhd
Copy link
Owner

pkujhd commented Jun 15, 2021

@jimil749 , i can't find your loader code, could you give me more infomations?

@pkujhd pkujhd added the need more info need more case information label Jun 15, 2021
@jimil749
Copy link
Author

@pkujhd
Copy link
Owner

pkujhd commented Jun 15, 2021

@jimil749, the loader looks ok, Did you strip the code on compile? if you strip it, the loader could not find symbol tables for runtime symbol.

@jimil749
Copy link
Author

I did not. I just followed this: https://github.com/pkujhd/goloader#examples (4th example) for compiling and loading.

@pkujhd
Copy link
Owner

pkujhd commented Jun 15, 2021

I did not. I just followed this: https://github.com/pkujhd/goloader#examples (4th example) for compiling and loading.

i test your code, it runs ok on macosx/amd64.

if you are not, please give me your runtime env, e.g. os version, golang version.

in addition, you need call main.New replace json.New. if you do not set package name, "main" is default

@jimil749
Copy link
Author

Ahh ok. I'll test it out once again.

Still I'll provide the runtime env:
go version go1.16.4 linux/amd64

os: Ubuntu 20.04

@pkujhd
Copy link
Owner

pkujhd commented Jun 15, 2021

Ahh ok. I'll test it out once again.

Still I'll provide the runtime env:
go version go1.16.4 linux/amd64

os: Ubuntu 20.04

i don't repeated your error

[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ go version
go version go1.16.4 linux/amd64
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ go build 
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ go install github.com/jimil749/reva-plugin-benchmark/pkg/plugins/goloader/manager
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ go tool compile -I $GOPATH/pkg/`go env GOOS`_`go env GOARCH` pkg/plugins/goloader/json.go 
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ ./reva-plugin-benchmark 
<nil>
&{users:[0xc000022080 0xc000022100 0xc000022180 0xc000022200]}[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ 
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ git status
# 头指针分离于 2dd5c5a
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ 

@jimil749
Copy link
Author

Hi @pkujhd! Thanks for the quick response. I tested this out again locally. Seems to be working.

I think the problem occurs when I directly do go run main.go. if i build the go binary first and then execute the loader, it works fine! But when I go run or even try to run benchmarks using go test -bench=., it seems to panic!

@pkujhd
Copy link
Owner

pkujhd commented Jun 15, 2021

ujhd! Thanks for the quick response. I tested this out again locally. Seems to be working.

I think the problem occurs when I directly do go run main.go. if i build the go binary first and then execute the loader, it works fine! But when I go run or even try to run benchmarks using go test -bench=., it seems to panic!

not support this used. when used go run on linux, the go used compile argument -s -w

mkdir -p $WORK/b001/exe/
cd .
/home/jhd/programs/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/main -importcfg $WORK/b001/importcfg.link -s -w -buildmode=exe -buildid=jmj3QMtnxUCnJO6fpCDt/0di_CXuKEyWJQkQN8UnQ/BuKplcEFQ7e9fQTeY9ic/jmj3QMtnxUCnJO6fpCDt -extld=gcc /home/jhd/.cache/go-build/c3/c3d53a237e452409beb3f013ed97318a20d9a9b758c9e5f52944b953c10b2054-d
$WORK/b001/exe/main
unresolve external:runtime.zerobase
fails in loading
panic: unresolve external:runtime.zerobase

goroutine 1 [running]:
main.main()
        /home/jhd/go/src/github.com/jimil749/reva-plugin-benchmark/main.go:46 +0x69c
exit status 2
[jhd@test-centos7-build-2-45 reva-plugin-benchmark]$ go run -x -v -work main.go

@pkujhd pkujhd closed this as completed Jun 15, 2021
@pkujhd pkujhd added question Further information is requested and removed need more info need more case information labels Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants