Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

segfault on wallet_import_private_key #253

Closed
wackou opened this issue Jun 9, 2014 · 5 comments
Closed

segfault on wallet_import_private_key #253

wackou opened this issue Jun 9, 2014 · 5 comments

Comments

@wackou
Copy link

wackou commented Jun 9, 2014

I am part of the delegates for the dry run, but I get a segfault when importing any of the private keys that correspond to the public ones I gave on bitsharestalk.

I am on commit 339072b

Stacktrace:

>>> wallet_import_private_key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6d0e10c in __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv
1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff6d0e10c in __cxxabiv1::__vmi_class_type_info::__do_dyncast(long, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxx
abiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff6d0b43d in __dynamic_cast () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007ffff6d35180 in bool std::has_facet<std::ctype<char> >(std::locale const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff6d2a084 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff6d2a128 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00000000006376a0 in basic_istream (__vtt_parm=<optimized out>, this=0x7ffff5cfd280, __in_chrg=<optimized out>) at /usr/include/c++/4.7/istream:606
#6  basic_iostream (__vtt_parm=<optimized out>, this=0x7ffff5cfd280, __in_chrg=<optimized out>) at /usr/include/c++/4.7/istream:825
#7  basic_stringstream (__m=24, this=0x7ffff5cfd280, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /usr/include/c++/4.7/sstream:519
#8  fc::file_appender::log (this=0x142a400, m=...) at /home/admin/dev/bitshares_toolkit/libraries/fc/src/log/file_appender.cpp:41
#9  0x0000000000635930 in fc::logger::log (this=0x7ffff5cfd5a0, m=...) at /home/admin/dev/bitshares_toolkit/libraries/fc/src/log/logger.cpp:68
#10 0x00000000007edae9 in bts::wallet::wallet_db::store_key (this=this@entry=0x1966880, key_to_store=...) at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet_db.cpp:278
#11 0x00000000007f312a in bts::wallet::wallet_db::add_contact_account (this=0x1966880, blockchain_account=..., private_data=...)
    at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet_db.cpp:425
#12 0x00000000007b4adf in bts::wallet::wallet::add_contact_account (this=this@entry=0x142f2f8, account_name=..., key=..., private_data=...)
    at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:718
#13 0x00000000007b6be2 in bts::wallet::wallet::import_private_key (this=this@entry=0x142f2f8, key=..., account_name=..., create_account=create_account@entry=false)
    at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:793
#14 0x00000000007b7cba in bts::wallet::wallet::import_wif_private_key (this=0x142f2f8, wif_key=..., account_name=..., create_account=false)
    at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:843
#15 0x00000000005b77f7 in bts::client::detail::client_impl::wallet_import_private_key (this=0x142ab10, wif_key_to_import=..., account_name=..., create_account=<optimized out>,
    wallet_rescan_blockchain=true) at /home/admin/dev/bitshares_toolkit/libraries/client/client.cpp:970
#16 0x000000000075aa9a in bts::rpc_stubs::common_api_client::wallet_import_private_key (this=0x142a8e8, wif_key=..., account_name=..., create_new_account=<optimized out>,
    rescan=true) at /home/admin/dev/bitshares_toolkit/libraries/rpc_stubs/common_api_client.cpp:220
#17 0x000000000072ddee in bts::rpc_stubs::common_api_rpc_server::wallet_import_private_key_positional (this=this@entry=0x142c0c0, json_connection=..., parameters=...)
    at /home/admin/dev/bitshares_toolkit/libraries/rpc_stubs/common_api_rpc_server.cpp:619
@wackou
Copy link
Author

wackou commented Jun 9, 2014

Note: if I first add the corresponding public key using wallet_add_contact_account and then import the private key, then I don't get the segfault but the following:

>>> wallet_import_private_key 5XXXXXXXXXXXXXXXXXXXXXXXXXXX
passphrase:
OK
10
false: Error parsing WIF private key
    {}
    th_a  wallet.cpp:846 import_wif_private_key

    {"account_name":""}
    th_a  wallet.cpp:848 import_wif_private_key

    {}
    th_a  common_api_client.cpp:222 wallet_import_private_key

    {"command":"wallet_import_private_key"}
    th_a  cli.cpp:576 execute_command

@wackou
Copy link
Author

wackou commented Jun 9, 2014

Note: this was done in a VPS, tried rebooting, fresh git pull, rm ~/.BitshareXTS, always happen the same way.

Tried it in a virtual box, and I don't get the segfault but the other message about error parsing WIF private key. The other weird thing is that it is listed correctly after that using wallet_list_receive_accounts

This all seems to hint at memory corruption that seems to happen somewhere, so I tried running it in valgrind, but that didn't help as there are too many other warning about uninitialized values and invalid reads (mostly from leveldb) and then some more where valgrind seems to lose track of things completely...

Let me know if there's anything I can do to help debug this.

@wackou
Copy link
Author

wackou commented Jun 10, 2014

tried export LC_ALL=POSIX as suggested on the forum, which makes things a little better, but not entirely yet, as I can now import 1 key correctly but it fails on the second one, or the 3rd one (non-deterministic, sometimes the same key works, sometimes it doesn't).

new stack trace:

>>> wallet_import_private_key 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff68d339d in std::locale::locale() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff68d339d in std::locale::locale() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff68d1047 in std::ios_base::_M_init() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007ffff68df119 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00000000006736d0 in basic_istream (__vtt_parm=<optimized out>, this=0x7ffff458c1e0, __in_chrg=<optimized out>) at /usr/include/c++/4.7/istream:606
#4  basic_iostream (__vtt_parm=<optimized out>, this=0x7ffff458c1e0, __in_chrg=<optimized out>) at /usr/include/c++/4.7/istream:825
#5  basic_stringstream (__m=24, this=0x7ffff458c1e0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /usr/include/c++/4.7/sstream:519
#6  fc::file_appender::log (this=0x146a400, m=...) at /home/admin/dev/bitshares_toolkit/libraries/fc/src/log/file_appender.cpp:41
#7  0x0000000000671960 in fc::logger::log (this=0x7ffff458c500, m=...) at /home/admin/dev/bitshares_toolkit/libraries/fc/src/log/logger.cpp:68
#8  0x0000000000827a39 in bts::wallet::wallet_db::store_key (this=this@entry=0x14ddfa0, key_to_store=...) at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet_db.cpp:281
#9  0x000000000082ab8e in bts::wallet::wallet_db::add_contact_account (this=0x14ddfa0, blockchain_account=..., private_data=...) at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet_db.cpp:428
#10 0x00000000007f2ed7 in bts::wallet::wallet::add_contact_account (this=this@entry=0x1482878, account_name=..., key=..., private_data=...) at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:726
#11 0x00000000007f5162 in bts::wallet::wallet::import_private_key (this=this@entry=0x1482878, key=..., account_name=..., create_account=create_account@entry=false)
    at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:804
#12 0x00000000007f6011 in bts::wallet::wallet::import_wif_private_key (this=0x1482878, wif_key=..., account_name=..., create_account=false) at /home/admin/dev/bitshares_toolkit/libraries/wallet/wallet.cpp:854
#13 0x00000000005f46d7 in bts::client::detail::client_impl::wallet_import_private_key (this=0x146ab10, wif_key_to_import=..., account_name=..., create_account=<optimized out>, wallet_rescan_blockchain=true)
    at /home/admin/dev/bitshares_toolkit/libraries/client/client.cpp:968
#14 0x00000000007a6c8a in bts::rpc_stubs::common_api_client::wallet_import_private_key (this=0x146a8e8, wif_key=..., account_name=..., create_new_account=<optimized out>, rescan=true)
    at /home/admin/dev/bitshares_toolkit/libraries/rpc_stubs/common_api_client.cpp:220
#15 0x000000000076880e in bts::rpc_stubs::common_api_rpc_server::wallet_import_private_key_positional (this=this@entry=0x146c0c0, json_connection=..., parameters=...)
    at /home/admin/dev/bitshares_toolkit/libraries/rpc_stubs/common_api_rpc_server.cpp:619
#16 0x000000000077a5af in bts::rpc_stubs::common_api_rpc_server::direct_invoke_positional_method (this=0x146c0c0, method_name=..., parameters=...)
    at /home/admin/dev/bitshares_toolkit/libraries/rpc_stubs/common_api_rpc_server.cpp:5462

tried also with export LANG=POSIX, didn't help more...

@wackou
Copy link
Author

wackou commented Jun 10, 2014

This seems to be related to a debian/ubuntu issue... On the 3 debian systems I tried it fails whereas on ubuntu I can correctly import 4 keys (and the last one is probably not registered).
I also tried to compile with both boost 1.54 and boost 1.55 and it still fails.

@wackou
Copy link
Author

wackou commented Jun 10, 2014

Found it! It was a problem with gcc 4.7, recompiling with gcc 4.8 solved all my issues...

@wackou wackou closed this as completed Jun 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant