hyperledger-archives / indy-sdk

indy-sdk
https://wiki.hyperledger.org/display/indy
Apache License 2.0
668 stars 735 forks source link

SIGSEGV running nodejs sample on Ubuntu 18.04 #1075

Closed asmallfurrywombat closed 6 years ago

asmallfurrywombat commented 6 years ago

Environment: Ubuntu 18.04.1 LTS Steps:

git clone -n https://github.com/hyperledger/indy-sdk.git
git checkout 78cd7625a03c7a9d64d5d63e143eeb8344d59b0d

build as per https://github.com/hyperledger/indy-sdk/blob/master/doc/ubuntu-build.md note: there is one warning during the libindy build:

warning: redundant linker flag specified for library zmq
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<directory containing the new libindy.so>
sudo ldconfig
cd <indy-sdk dir>/wrappers/nodejs
cp -r ../../libindy/include/ .
npm i
RUST_LOG=trace TEST_POOL_IP=10.0.0.2 npm test
first 4 tests pass, the rest timeout
cd <indy-sdk dir>/samples/nodejs
npm run ledger
cp ../../libindy/include/*.h .
npm i
ulimit -c unlimited
rm -rf ~/.indy_client
rm -rf /tmp/indy
npm start
"Government" > Create and store in Wallet "Government Sovrin Steward" DID
"Government" > Get key for did from "Sovrin Steward" connection request
"Government" > Anoncrypt connection response for "Sovrin Steward" with "Government Sovrin Steward" DID, verkey and nonce
Segmentation fault (core dumped)

The crash occurs at gettingStarted.js(695) during a call to capi.cryptoAnonCrypt().

rust-lldb node -c ./core
bt
* thread #1, name = 'node', stop reason = signal SIGSEGV
  * frame #0: 0x00007f1706081235 libzmq.so.5`core.constprop.5 + 21
    frame #1: 0x00007f1706084b79 libzmq.so.5`crypto_core_hsalsa20 + 9
    frame #2: 0x00007f1707663fec libindy.so`crypto_secretbox_detached(c=&0x7f16ec0815c0, mac=&0x7f16ec0815b0, m=&0x55bb7ae7c490, mlen=104, n=&0x7f16f7ff91a0, k=<unavailable>) at crypto_secretbox_easy.c:28
    frame #3: 0x00007f1707660c7b libindy.so`crypto_box_detached [inlined] crypto_box_detached_afternm(k=&0x7f16f7ff9100, n=&0x7f16f7ff91a0, mlen=104, m=&0x55bb7ae7c490, mac=&0x7f16ec0815b0, c=&0x7f16ec0815c0) at crypto_box_easy.c:17
    frame #4: 0x00007f1707660c64 libindy.so`crypto_box_detached(c=&0x7f16ec0815c0, mac=&0x7f16ec0815b0, m=&0x55bb7ae7c490, mlen=104, n=&0x7f16f7ff91a0, pk=<unavailable>, sk=&0x7f16f7ff91e0) at crypto_box_easy.c:33
    frame #5: 0x00007f1707660d1b libindy.so`crypto_box_easy(c=<unavailable>, m=<unavailable>, mlen=<unavailable>, n=<unavailable>, pk=<unavailable>, sk=<unavailable>) at crypto_box_easy.c:59
    frame #6: 0x00007f1707660f8c libindy.so`crypto_box_seal(c=&0x7f16ec081590, m=&0x55bb7ae7c490, mlen=104, pk=&0x7f16f7ff93a0) at crypto_box_seal.c:37
    frame #7: 0x00007f170705772d libindy.so`sodiumoxide::crypto::sealedbox::curve25519blake2bxsalsa20poly1305::seal::h9082a90ee8af882f(m=&['{', '"', 'd', 'i', 'd', '"', ':', '"', 'Z', 'h', 'L', 'D', 'G', 'A', 'd', 'z', 'R', 'R', 'a', 'c', 'D', 'k', 'u', 'B', 'V', 'k', 'y', 'a', 'e', '"', ',', '"', 'v', 'e', 'r', 'k', 'e', 'y', '"', ':', '"', 'J', 'p', 'Z', 'm', 'a', 'd', 'X', 'M', 'g', 'b', 'e', 'C', 'Y', 'Q', 'w', 's', 'G', '6', 'N', '6', 'R', 'j', 'o', '9', 'V', 'b', 'F', 'P', 'W', '1', '6', 'J', 'L', 'A', '6', '7', 'D', '3', 'g', '9', 'L', 'h', 'N', '"', ',', '"', 'n', 'o', 'n', 'c', 'e', '"', ':', '1', '2', '3', '4', '5', '6', '7', '8', '9', '}'], (null)=&0x7f16f7ff93a0) at curve25519blake2bxsalsa20poly1305.rs:23
.
. 
.

Analysis of the core shows it originates in libzmq.so.5 . The instructions specify installation of libzmq3-dev, which contains libzmq.so.3, so perhaps this is the source of the problem. Digging into it. If someone knows of a setup to trace into such problems it would be appreciated. Perhaps Eclipse Photon?

asmallfurrywombat commented 6 years ago

Working now. An ldconfig seemed to resolve the issue. I'm also publishing the wrapper module to a local node package manager. If anyone else is looking into this, vscode with an lldb extension seems to be usable for tracing into the rust stack and it can also debug at the javascript layer.