pocketnetteam / pocketnet.core

Decentralized social network based on the blockchain
https://pocketnet.app
Apache License 2.0
114 stars 28 forks source link

getstakereport crashes with SIGABRT in debug build #130

Closed tawmaz closed 2 years ago

tawmaz commented 2 years ago

Running getstakereport on 0.20.17 release candidate built with --enable-debug causes a crash with SIGABRT here: https://github.com/pocketnetteam/pocketnet.core/blob/feature/sqlite/src/sync.cpp#L161 I recall seeing this crash back even with reindexer so I do not think this is a new issue.

stack:

Thread 10 "pocketcoin-http" received signal SIGABRT, Aborted.
[Switching to Thread 0x7f5aad60a700 (LWP 278982)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f5ab37b9859 in __GI_abort () at abort.c:79
#2  0x0000563a8f008da1 in AssertLockHeldInternal (pszName=pszName@entry=0x563a8f231fea "cs_main", 
    pszFile=pszFile@entry=0x563a8f30ad03 "wallet/wallet.cpp", nLine=nLine@entry=4316, cs=0x563a8f5046c0 <cs_main>) at sync.cpp:161
#3  0x0000563a8ef05e16 in CMerkleTx::GetDepthInMainChain (this=this@entry=0x563a9df176f0) at wallet/wallet.cpp:4316
#4  0x0000563a8eebdac6 in GetsStakeSubTotal (aRange=std::vector of length 35, capacity 64 = {...}) at wallet/rpcwallet.cpp:4121
#5  0x0000563a8eec2422 in getstakereport (request=...) at wallet/rpcwallet.cpp:4247
#6  0x0000563a8eabd593 in CRPCTable::execute (this=this@entry=0x563a909be328, request=...) at rpc/server.cpp:457
#7  0x0000563a8eda007c in HTTPSocket::HTTPReq (this=<optimized out>, req=req@entry=0x563ab1b21fe0, table=...) at httpserver.cpp:789
#8  0x0000563a8ed984ba in HTTPReq_JSONRPC (req=0x563ab1b21fe0) at httprpc.cpp:126
#9  0x0000563a8ea8aa8b in std::_Function_handler<bool (HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), bool (*)(HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::_M_invoke(std::_Any_data const&, HTTPRequest*&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (
    __functor=..., __args#0=<optimized out>, __args#1=...) at /usr/include/c++/9/bits/std_function.h:88
#10 0x0000563a8eda2d2c in std::function<bool (HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator()(HTTPRequest*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (
    this=this@entry=0x563ab0cf0f00, __args#0=<optimized out>, __args#0@entry=0x563ab1b21fe0, __args#1="")
    at /usr/include/c++/9/bits/std_function.h:263
#11 0x0000563a8eda2d88 in HTTPWorkItem::operator() (this=0x563ab0cf0ed0, dbConnection=...) at ./httpserver.h:237
#12 0x0000563a8eda1375 in WorkQueue<HTTPClosure>::Run (selfDbConnection=<optimized out>, this=0x563a90a49760)
    at /usr/include/c++/9/bits/unique_lock.h:103
#13 HTTPWorkQueueRun (queue=0x563a90a49760, selfDbConnection=<optimized out>) at httpserver.cpp:374
#14 0x0000563a8eda1db3 in std::__invoke_impl<void, void (*)(WorkQueue<HTTPClosure>*, bool), WorkQueue<HTTPClosure>*, bool> (
    __f=<optimized out>) at /usr/include/c++/9/bits/invoke.h:89
#15 std::__invoke<void (*)(WorkQueue<HTTPClosure>*, bool), WorkQueue<HTTPClosure>*, bool> (__fn=<optimized out>)
    at /usr/include/c++/9/bits/invoke.h:95
#16 std::thread::_Invoker<std::tuple<void (*)(WorkQueue<HTTPClosure>*, bool), WorkQueue<HTTPClosure>*, bool> >::_M_invoke<0ul, 1ul, 2ul>
    (this=<optimized out>) at /usr/include/c++/9/thread:244
#17 std::thread::_Invoker<std::tuple<void (*)(WorkQueue<HTTPClosure>*, bool), WorkQueue<HTTPClosure>*, bool> >::operator() (
    this=<optimized out>) at /usr/include/c++/9/thread:251
#18 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(WorkQueue<HTTPClosure>*, bool), WorkQueue<HTTPClosure>*, bool> > >::_M_run (this=<optimized out>) at /usr/include/c++/9/thread:195
#19 0x00007f5ab3bc8de4 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#20 0x00007f5ab42f6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007f5ab38b6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

frame 2 locals and args:

(gdb) frame 2
#2  0x0000563a8f008da1 in AssertLockHeldInternal (pszName=pszName@entry=0x563a8f231fea "cs_main", 
    pszFile=pszFile@entry=0x563a8f30ad03 "wallet/wallet.cpp", nLine=nLine@entry=4316, cs=0x563a8f5046c0 <cs_main>) at sync.cpp:161
161     sync.cpp: No such file or directory.
(gdb) info args
pszName = 0x563a8f231fea "cs_main"
pszFile = 0x563a8f30ad03 "wallet/wallet.cpp"
nLine = 4316
cs = 0x563a8f5046c0 <cs_main>
(gdb) info locals
No locals.

frame 3 locals and args:

(gdb) frame 3
#3  0x0000563a8ef05e16 in CMerkleTx::GetDepthInMainChain (this=this@entry=0x563a9df176f0) at wallet/wallet.cpp:4316
4316    wallet/wallet.cpp: No such file or directory.
(gdb) info args
this = 0x563a9df176f0
(gdb) info locals
pindex = <optimized out>
andyoknen commented 2 years ago

@tawmaz Do you have conditions or steps to reproduce?

tawmaz commented 2 years ago

Here is the my setup:

Setting ports

publicrpcport=38081 wsport=8087

Setting work queue and threads

rpcpublicworkqueue=3000 rpcpublicthreads=30 rpcpostworkqueue=1500 rpcpostthreads=15

tawmaz commented 2 years ago

Fix which I think we should hold for 0.20.18 release: https://github.com/pocketnetteam/pocketnet.core/pull/131

andyoknen commented 2 years ago

Fix which I think we should hold for 0.20.18 release: #131

Why do you think it should be moved to 0.20.18? I think this is a good change for 0.20.17

tawmaz commented 2 years ago

I would need to restart 0.20.17 testing from the beginning if we accept this patch. It is a simple patch but there is always the possibility of introducing deadlocks or other serious issue. As far as impact to the community this issue is only visible in debug builds so I think it is okay to wait a few weeks for release.

andyoknen commented 2 years ago

This fix is being migrated to version 0.20.18