Closed wafeishushu closed 2 years ago
Hi,
Can you show the output of ldd myprogramme
?
It's probably not related to your problem, but you should update the EGo installation as well as the dependency in go.mod to v1.0.1.
Hi @thomasten , thanks! here is my output, the SGX machine of our project use EGo v0.5.0, so I can only use this version.
$ ldd myprogramme
linux-vdso.so.1 (0x00007ffed1dfc000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fdca299f000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fdca2983000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdca2834000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fdca2811000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdca27f6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdca2604000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdca373f000)
Just to be sure: the helloworld sample is working, right?
It seems that your program or one of its dependencies use cgo. EGo's support for cgo is experimental. Most notably, libraries (except libc and its helpers) must be linked statically. See the cgo sample.
Yep, the helloworld sample works normally, but I can't run cgo sample properly.
$ ego-go build
$ ls
README.md cgo go.mod main.go
$ ego sign cgo
EGo v0.5.0 (55bad14bb8d00dbae2000a8d603f9b588bb79451)
Generating new private.pem
/opt/ego/bin/ego-oesign ERROR: oe_sgx_build_enclave(): result=OE_FAILURE (0x1)
2022-09-22T14:05:33+0000.599041Z [(H)ERROR] tid(0x7f8d638bcb80) | symbol not found: zlibVersion [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_link_elf_image:808]
2022-09-22T14:05:33+0000.609893Z [(H)ERROR] tid(0x7f8d638bcb80) | 1 symbols not found (oe_result_t=OE_UNSUPPORTED_ENCLAVE_IMAGE) [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_link_elf_image:826]
2022-09-22T14:05:33+0000.609896Z [(H)ERROR] tid(0x7f8d638bcb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_patch_relocations:1193]
2022-09-22T14:05:33+0000.609897Z [(H)ERROR] tid(0x7f8d638bcb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:oe_load_elf_enclave_image:1500]
2022-09-22T14:05:33+0000.610182Z [(H)ERROR] tid(0x7f8d638bcb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/load.c:oe_load_enclave_image:66]
2022-09-22T14:05:33+0000.610185Z [(H)ERROR] tid(0x7f8d638bcb80) | :OE_FAILURE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/create.c:oe_sgx_build_enclave:909]
$ ldd cgo
linux-vdso.so.1 (0x00007ffe2b5e4000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4bc0dd9000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4bc0db6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4bc0bc4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4bc0f76000)
This is strange. The line https://github.com/edgelesssys/ego/blob/a0aabbdd677e733985aec93ebee80132a85b18f0/samples/cgo/main.go#L3 should link the static version of libz, but your ldd output shows that it's linked dynamically. You can try changing this line to
// #cgo LDFLAGS: -Wl,-Bstatic -lz -Wl,-Bdynamic
which is another way of forcing it to link statically.
I change the line 3 as above, but still got the same error.
$ ego sign cgo
EGo v0.5.0 (55bad14bb8d00dbae2000a8d603f9b588bb79451)
Generating new private.pem
/opt/ego/bin/ego-oesign ERROR: oe_sgx_build_enclave(): result=OE_FAILURE (0x1)
2022-09-23T01:04:55+0000.503390Z [(H)ERROR] tid(0x7ff4b10dfb80) | symbol not found: zlibVersion [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_link_elf_image:808]
2022-09-23T01:04:55+0000.514207Z [(H)ERROR] tid(0x7ff4b10dfb80) | 1 symbols not found (oe_result_t=OE_UNSUPPORTED_ENCLAVE_IMAGE) [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_link_elf_image:826]
2022-09-23T01:04:55+0000.514209Z [(H)ERROR] tid(0x7ff4b10dfb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_patch_relocations:1193]
2022-09-23T01:04:55+0000.514210Z [(H)ERROR] tid(0x7ff4b10dfb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:oe_load_elf_enclave_image:1500]
2022-09-23T01:04:55+0000.514547Z [(H)ERROR] tid(0x7ff4b10dfb80) | :OE_UNSUPPORTED_ENCLAVE_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/load.c:oe_load_enclave_image:66]
2022-09-23T01:04:55+0000.514549Z [(H)ERROR] tid(0x7ff4b10dfb80) | :OE_FAILURE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/create.c:oe_sgx_build_enclave:909]
I replace badger db to rocksdb, which makes myprogramme
without cgo. Then I run ego sign
successfully.
But it seems the badger db cannot run at ego mode. I got errors when running ego run myprogramme
:
$ ego run myprogramme
EGo v0.5.0 (55bad14bb8d00dbae2000a8d603f9b588bb79451)
[erthost] loading enclave ...
[erthost] entering enclave ...
[ego] starting application ...
runtime: out of memory: cannot allocate 88080384-byte block (7766016 in use)
fatal error: out of memory
goroutine 1 [running]:
runtime.throw({0x7f7c81b85782?, 0x299a?})
/opt/ego/go/src/runtime/panic.go:992 +0x71 fp=0x7f7c985bf140 sp=0x7f7c985bf110 pc=0x7f7c8161dab1
runtime.(*mcache).allocLarge(0x7f7c980021a0?, 0x53332f9, 0x1)
/opt/ego/go/src/runtime/mcache.go:215 +0x1d9 fp=0x7f7c985bf190 sp=0x7f7c985bf140 pc=0x7f7c815ff359
runtime.mallocgc(0x53332f9, 0x7f7c81cc7560, 0x1)
/opt/ego/go/src/runtime/malloc.go:1101 +0x5a5 fp=0x7f7c985bf208 sp=0x7f7c985bf190 pc=0x7f7c815f57a5
runtime.makeslice(0x7f7c81aca1bd?, 0x7f7c9826f280?, 0x6?)
/opt/ego/go/src/runtime/slice.go:103 +0x52 fp=0x7f7c985bf230 sp=0x7f7c985bf208 pc=0x7f7c81634392
github.com/dgraph-io/badger/v3/skl.newArena(...)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/skl/arena.go:48
github.com/dgraph-io/badger/v3/skl.NewSkiplist(0x53332f9)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/skl/skl.go:130 +0x32 fp=0x7f7c985bf2b0 sp=0x7f7c985bf230 pc=0x7f7c81a8cf12
github.com/dgraph-io/badger/v3.(*DB).openMemTable(0x7f7c980d5b00, 0x1, 0x7f7c82463108?)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:112 +0xbe fp=0x7f7c985bf4b0 sp=0x7f7c985bf2b0 pc=0x7f7c81ac997e
github.com/dgraph-io/badger/v3.(*DB).newMemTable(0x7f7c980d5b00)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/memtable.go:153 +0x2e fp=0x7f7c985bf528 sp=0x7f7c985bf4b0 pc=0x7f7c81ac9f0e
github.com/dgraph-io/badger/v3.Open({{0x7f7c81b827a0, 0x9}, {0x7f7c81b827a0, 0x9}, 0x0, 0x1, 0x0, {0x7f7c81d9df60, 0x7f7c98172bd0}, 0x1, ...})
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:338 +0xf07 fp=0x7f7c985bfc48 sp=0x7f7c985bf528 pc=0x7f7c81a9f2e7
main.mustOpenDB()
/home/azureuser/airdrop_tools/tofixedset/main.go:326 +0x7b fp=0x7f7c985bff30 sp=0x7f7c985bfc48 pc=0x7f7c81b6139b
main.main()
/home/azureuser/airdrop_tools/tofixedset/main.go:370 +0x2e fp=0x7f7c985bff80 sp=0x7f7c985bff30 pc=0x7f7c81b6144e
runtime.main()
/opt/ego/go/src/runtime/proc.go:251 +0x212 fp=0x7f7c985bffe0 sp=0x7f7c985bff80 pc=0x7f7c816201d2
runtime.goexit()
/opt/ego/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0x7f7c985bffe8 sp=0x7f7c985bffe0 pc=0x7f7c8164dee1
goroutine 19 [chan receive]:
github.com/golang/glog.(*loggingT).flushDaemon(0x0?)
/home/azureuser/godata/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:882 +0x6a
created by github.com/golang/glog.init.0
/home/azureuser/godata/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:410 +0x1bf
goroutine 20 [select]:
github.com/dgraph-io/badger/v3/y.(*WaterMark).process(0x7f7c981db740, 0x7f7c981db710)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/y/watermark.go:214 +0x285
created by github.com/dgraph-io/badger/v3/y.(*WaterMark).Init
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/y/watermark.go:72 +0xaa
goroutine 21 [select]:
github.com/dgraph-io/badger/v3/y.(*WaterMark).process(0x7f7c981db770, 0x7f7c981db710)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/y/watermark.go:214 +0x285
created by github.com/dgraph-io/badger/v3/y.(*WaterMark).Init
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/y/watermark.go:72 +0xaa
goroutine 22 [select]:
github.com/dgraph-io/ristretto/z.(*AllocatorPool).freeupAllocators(0x7f7c980a0db0)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/allocator.go:385 +0x150
created by github.com/dgraph-io/ristretto/z.NewAllocatorPool
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/z/allocator.go:324 +0xc5
goroutine 23 [select]:
github.com/dgraph-io/ristretto.(*defaultPolicy).processItems(0x7f7c980a4ac0)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/policy.go:102 +0x91
created by github.com/dgraph-io/ristretto.newDefaultPolicy
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/policy.go:86 +0x156
goroutine 6 [select]:
github.com/dgraph-io/ristretto.(*Cache).processItems(0x7f7c98116380)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/cache.go:452 +0x15e
created by github.com/dgraph-io/ristretto.NewCache
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/ristretto@v0.1.0/cache.go:207 +0x696
goroutine 7 [select]:
github.com/dgraph-io/badger/v3.(*DB).monitorCache(0x7f7c980d5b00, 0x7f7c98546000)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:469 +0x18a
created by github.com/dgraph-io/badger/v3.Open
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:311 +0xc8b
goroutine 8 [select]:
github.com/dgraph-io/badger/v3.(*DB).updateSize(0x7f7c980d5b00, 0x7f7c98546150)
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:1171 +0x158
created by github.com/dgraph-io/badger/v3.Open
/home/azureuser/godata/pkg/mod/github.com/dgraph-io/badger/v3@v3.2103.2/db.go:331 +0xe8c
See troubleshooting docs on how to handle out of memory.
Also note that you must set Badger's ValueLogLoadingMode
and TableLoadingMode
to FileIO
because EGo doesn't support memory-mapped files. This seems to be removed in Badger v3, so you need to use v2.
Thank you @thomasten !
Issue description
get lots of errors when
ego sign
To reproduce
Steps to reproduce the behavior:
first run
ego-go build
and getmyprogramme
then
$ ego sign myprogramme
and get errors
Additional info
my
ego
dependency in go.mod:could you pls help me to take a look of this? thanks!