pandanite-crypto / pandanite

Simple, elegant, fast, Layer-1 blockchain based cryptocurrency written in 6k lines of C++
MIT License
30 stars 40 forks source link

cli segfault #79

Closed f10crypto closed 1 year ago

f10crypto commented 2 years ago

Running the cli and waiting a couple of seconds will result in a segfault.

Thread 25 "cli" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6612700 (LWP 21066)]
0x00005555557e4ce7 in PufferfishCache::getHash (this=0x7fffd8001130, hash=...)
    at /root/bamboo/src/server/pufferfish_cache.cpp:22
22          leveldb::Status status = db->Get(leveldb::ReadOptions(), sha256ToSlice(hash), &value);

gdb backtrace:

#0  0x00005555557e4ce7 in PufferfishCache::getHash (this=0x7fffd8001130,
    hash=...) at /root/bamboo/src/server/pufferfish_cache.cpp:22
#1  0x0000555555796ae8 in PUFFERFISH (
    buffer=0x7ffff6611990 "\234\214\347\017\211\376\241\247b\227\\\372s\216>]\200\331", len=64, useCache=true) at /root/bamboo/src/core/crypto.cpp:31
#2  0x0000555555796e39 in SHA256 (
    buffer=0x7ffff6611990 "\234\214\347\017\211\376\241\247b\227\\\372s\216>]\200\331", len=64, usePufferFish=true, useCache=true)
    at /root/bamboo/src/core/crypto.cpp:53
#3  0x0000555555797e27 in concatHashes (a=..., b=..., usePufferFish=true,
    useCache=true) at /root/bamboo/src/core/crypto.cpp:224
#4  0x0000555555797fed in verifyHash (target=..., nonce=...,
    challengeSize=6 '\006', usePufferFish=true, useCache=true)
    at /root/bamboo/src/core/crypto.cpp:246
#5  0x0000555555774985 in Block::verifyNonce (this=0x7ffff6611c70)
    at /root/bamboo/src/core/block.cpp:155
#6  0x000055555579ab3d in HeaderChain::load (this=0x555555e7ea10)
    at /root/bamboo/src/core/header_chain.cpp:107
#7  0x000055555579a1d3 in chain_sync (chain=...)
    at /root/bamboo/src/core/header_chain.cpp:13
#8  0x000055555579c5d4 in std::__invoke_impl<void, void (*)(HeaderChain&), std::reference_wrapper<HeaderChain> > (
    __f=@0x555555e7dcc0: 0x55555579a1ac <chain_sync(HeaderChain&)>)

should the cli even be doing a header chain sync?

f10crypto commented 2 years ago

just to make sure i just did a fresh install on ubuntu 20.04 -> make keygen and cli -> generate keys -> run cli -> wait 20 seconds -> segfault

J-Ttt commented 1 year ago

Fixed with: https://github.com/pandanite-crypto/pandanite/commit/2f6f1a9c7eb9ae866fb71b35b1d1cf9f7ae1d4b4