herumi / bls

288 stars 133 forks source link

Testing: Unexpected signal during runtime execution #39

Closed jenil04 closed 4 years ago

jenil04 commented 4 years ago

I am configuring and setting up the 0chain SDK, by installing BLS and MCL Dependencies. Upon using 'make install' I get the following error.

Please help me mitigate this.

Error:

(SeqRead) buf=000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
(rand.Reader) buf=6c3724fc88dd295f7146eb3f526b93cb18aa043b939803c15c616af6af914113
(default) buf=ce1960f68878a9d3909a5c884fc0a7d2f72fcaccd128b31ffe4109b2603d5b15
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff727ea476]

runtime stack:
runtime.throw(0x4186159, 0x2a)
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/panic.go:774 +0x72
runtime.sigpanic()
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/signal_unix.go:378 +0x47c

goroutine 20 [syscall]:
runtime.cgocall(0x41259f0, 0xc000045e00, 0x1)
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/cgocall.go:128 +0x5b fp=0xc000045dd0 sp=0xc000045d98 pc=0x40056bb
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls._Cfunc_blsGetPublicKey(0xc0000ca0c0, 0xc0000c6200)
    _cgo_gotypes.go:189 +0x41 fp=0xc000045e00 sp=0xc000045dd0 pc=0x411fb21
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls.(*SecretKey).GetPublicKey(...)
    /Users/jenilthakker/go/github.com/0chain/gosdk/_herumi/bls/ffi/go/bls/bls.go:505
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls.testPre(0xc0000c0100)
    /Users/jenilthakker/go/github.com/0chain/gosdk/_herumi/bls/ffi/go/bls/bls_test.go:54 +0x664 fp=0xc000045ed0 sp=0xc000045e00 pc=0x4119b74
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls.test(0xc0000c0100, 0x0)
    /Users/jenilthakker/go/github.com/0chain/gosdk/_herumi/bls/ffi/go/bls/bls_test.go:493 +0x116 fp=0xc000045f20 sp=0xc000045ed0 pc=0x411e2e6
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls.TestMain(0xc0000c0100)
    /Users/jenilthakker/go/github.com/0chain/gosdk/_herumi/bls/ffi/go/bls/bls_test.go:512 +0xee fp=0xc000045f70 sp=0xc000045f20 pc=0x411e4ae
testing.tRunner(0xc0000c0100, 0x41880b0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:909 +0xc9 fp=0xc000045fd0 sp=0xc000045f70 pc=0x40c2bc9
runtime.goexit()
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000045fd8 sp=0xc000045fd0 pc=0x405c5d1
created by testing.(*T).Run
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:960 +0x350

goroutine 1 [chan receive]:
testing.(*T).Run(0xc0000c0100, 0x417ea19, 0x8, 0x41880b0, 0x40736f6)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:961 +0x377
testing.runTests.func1(0xc0000c0000)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1202 +0x78
testing.tRunner(0xc0000c0000, 0xc000044dc0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:909 +0xc9
testing.runTests(0xc00009e060, 0x428c2b0, 0x1, 0x1, 0x0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1200 +0x2a7
testing.(*M).Run(0xc0000ba000, 0x0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1117 +0x176
main.main()
    _testmain.go:68 +0x135
FAIL    github.com/0chain/gosdk/_herumi/bls/ffi/go/bls  1.398s
FAIL
make[1]: *** [test_go256] Error 1
make: *** [test-herumi] Error 2
herumi commented 4 years ago

I've not tested 0chain SDK yet.

/usr/local/Cellar/go/1.13.3/libexec/src/runtime/cgocall.go:128 +0x5b fp=0xc000045dd0 sp=0xc000045d98 pc=0x40056bb
github.com/0chain/gosdk/_herumi/bls/ffi/go/bls._Cfunc_blsGetPublicKey(0xc0000ca0c0, 0xc0000c6200)

blsGetPublicKey never outputs an error. Have you installed mcl/bls before? Could you check which these libraries in /usr/local/install and /usr/local/lib and remove all if exists?

Could you show me what OS/environments? I do not 0chain, which step did you got at guide?

To isolate the problem, could you run the following command?

mkdir work
cd work
git clone http://github.com/herumi/mcl
git clone http://github.com/herumi/bls
cd bls
make test_go256

Does the test run well?

jenil04 commented 4 years ago

Thank you for the suggestion. After testing independently, I get the following error:

cd ffi/go/bls && env PATH=$PATH:"../../../lib:../../../../mcl/lib" LD_LIBRARY_PATH="../../../lib:../../../../mcl/lib" DYLD_LIBRARY_PATH="../../../lib:../../../../mcl/lib" CGO_LDFLAGS="-L../../../lib -L/usr/local/opt/openssl/lib" CGO_CFLAGS="-I/Users/jenilthakker/desktop/work/bls/include -I/Users/jenilthakker/desktop/work/bls/../mcl/include" go test -tags bn256 .
(SeqRead) buf=000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
(rand.Reader) buf=1221e68fec511eb6990de10e21e07dd59c3a76258bc4f1de9ceeec0aa2de6923
(default) buf=abe720a8c332913e4f823267d8507de8c5e93cae47d543e8f0387f5074bed112
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff727ea476]

runtime stack:
runtime.throw(0x4186079, 0x2a)
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/panic.go:774 +0x72
runtime.sigpanic()
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/signal_unix.go:378 +0x47c

goroutine 20 [syscall]:
runtime.cgocall(0x4125910, 0xc000041e00, 0x1)
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/cgocall.go:128 +0x5b fp=0xc000041dd0 sp=0xc000041d98 pc=0x40055eb
_/Users/jenilthakker/desktop/work/bls/ffi/go/bls._Cfunc_blsGetPublicKey(0xc0000c20c0, 0xc0000c0200)
    _cgo_gotypes.go:189 +0x41 fp=0xc000041e00 sp=0xc000041dd0 pc=0x411fa51
_/Users/jenilthakker/desktop/work/bls/ffi/go/bls.(*SecretKey).GetPublicKey(...)
    /Users/jenilthakker/desktop/work/bls/ffi/go/bls/bls.go:505
_/Users/jenilthakker/desktop/work/bls/ffi/go/bls.testPre(0xc0000ba100)
    /Users/jenilthakker/desktop/work/bls/ffi/go/bls/bls_test.go:54 +0x664 fp=0xc000041ed0 sp=0xc000041e00 pc=0x4119aa4
_/Users/jenilthakker/desktop/work/bls/ffi/go/bls.test(0xc0000ba100, 0x0)
    /Users/jenilthakker/desktop/work/bls/ffi/go/bls/bls_test.go:493 +0x116 fp=0xc000041f20 sp=0xc000041ed0 pc=0x411e216
_/Users/jenilthakker/desktop/work/bls/ffi/go/bls.TestMain(0xc0000ba100)
    /Users/jenilthakker/desktop/work/bls/ffi/go/bls/bls_test.go:512 +0xee fp=0xc000041f70 sp=0xc000041f20 pc=0x411e3de
testing.tRunner(0xc0000ba100, 0x4187ea8)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:909 +0xc9 fp=0xc000041fd0 sp=0xc000041f70 pc=0x40c2af9
runtime.goexit()
    /usr/local/Cellar/go/1.13.3/libexec/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000041fd8 sp=0xc000041fd0 pc=0x405c501
created by testing.(*T).Run
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:960 +0x350

goroutine 1 [chan receive]:
testing.(*T).Run(0xc0000ba100, 0x417e939, 0x8, 0x4187ea8, 0x4073626)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:961 +0x377
testing.runTests.func1(0xc0000ba000)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1202 +0x78
testing.tRunner(0xc0000ba000, 0xc000040dc0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:909 +0xc9
testing.runTests(0xc000098080, 0x428c2b0, 0x1, 0x1, 0x0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1200 +0x2a7
testing.(*M).Run(0xc0000b6000, 0x0)
    /usr/local/Cellar/go/1.13.3/libexec/src/testing/testing.go:1117 +0x176
main.main()
    _testmain.go:68 +0x135
FAIL    _/Users/jenilthakker/desktop/work/bls/ffi/go/bls    1.084s
FAIL
make: *** [test_go256] Error 1

I am using MacOS Catalina (10.15). I am following these steps to setup the SDK.

I have used 'make install' before which may have the dependencies installed twice. However using 'make clean' should fix it? The paths /usr/local/install and /usr/local/lib do not contain any explicit libraries that say 'bls' or 'mcl'.

Thanks again.

herumi commented 4 years ago

Thank you for your report. I reproduced your bug on Catalina.

But I found that cd bls && make test_go256 MCL_USE_GMP=0 runs well after make clean on mcl and bls.

I will look into the reason.

For the workaround, I guess how about appending MCL_USE_GMP=0 to herumi.mk

jenil04 commented 4 years ago

I tested the command and that solves the error. I appended 'MCL_USE_GMP=0' as follows:

build-herumi:
    @$(PRINT_MAG)
    @echo "Building BLS: branch=$(bls_branch)"
    @$(PRINT_NON)
    $(MAKE) -C $(BLS_DIR) -j $(NPROC) lib/libbls256.a MCL_USE_GMP=0
    @$(PRINT_MAG)
    @echo "Building MCL: branch=$(mcl_branch)"
    @$(PRINT_NON)
    $(MAKE) -C $(MCL_DIR) -j $(NPROC) lib/libmclbn256.a MCL_USE_GMP=0

Here is the error I get after I use 'make install' on the gosdk repository:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libmclbn256.dylib] Error 1
make[1]: *** [/Users/jenilthakker/go/github.com/0chain/gosdk/_herumi/bls/../mcl/lib/libmcl.a] Error 2
make: *** [test-herumi] Error 2
herumi commented 4 years ago

I found that there are some reports for GMP on Catalina.

segmentation fault in t-toom53 test with MAC OS X Catalina (Clang 11.0) https://www.mail-archive.com/gmp-bugs@gmplib.org/msg00779.html

Report: gmp-6.1.2 on MacOS 10.15 using GCC and two Clang https://www.mail-archive.com/gmp-bugs@gmplib.org/msg00766.html

herumi commented 4 years ago

Here is the error I get after I use 'make install' on the gosdk repository:

It was because MCL_USE_GMP=0 option was not refered in the test. This patch disables GMP if Catalina, then I verified that the test is okay if changing from master to dev in herumi.mk.

But some tests fails without GMP yet. It runs well with g++-9 not clang though my code may have bugs (all tests run well on Linux).

Catalina seems to have several bugs, so I think we should avoid it for a while. search catalina macos segfault

jenil04 commented 4 years ago

Thank you for the help. The build works fine now!