Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault on ARM device #75

Closed
anthony-cros opened this issue Nov 6, 2015 · 15 comments
Closed

Segmentation Fault on ARM device #75

anthony-cros opened this issue Nov 6, 2015 · 15 comments
Assignees

Comments

@anthony-cros
Copy link

I cross-compiled eth for ARM and tried running it on a tizen phone. I'm getting a seg fault about 2 seconds after starting the program (no logs). I went ahead and re-compiled with debug on, and here was the result (duplicate lines removed):

Starting program: /opt/usr/media/151103215114.3/bin/eth 
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
warning: the debug information found in "/usr/lib/debug/lib/libc-2.20-2014.11.so.debug" does not match "/lib/libc.so.6" (CRC mismatch).
warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)
Program received signal SIGSEGV, Segmentation fault.
CryptoPP::BufferedTransformation::ChannelPut2(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char const*, unsigned int, int, bool) (warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

) at cryptlib.cpp:356
356    cryptlib.cpp: No such file or directory.
    in cryptlib.cpp

The sources for CryptoPP definitely contain a ./cryptlib.cpp and the logs of compilation don't seem to show anything unusual about this file: https://gist.github.com/anthony-cros/1540ff3393b0926ccce7

@gavofyork
Copy link
Contributor

run in gdb and grab a backtrace?

@anthony-cros
Copy link
Author

Hey @gavofyork , actually the excerpt above was run in gdb already, although I had only enabled it for libweb3core, libethereum and webthree, but none of the dependencies

@LefterisJP
Copy link
Contributor

What is the result of asking for a backtrace? Type bt and press enter after the segfault.

@anthony-cros
Copy link
Author

here's the backtrace:

(gdb) bt
warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

#0  CryptoPP::BufferedTransformation::ChannelPut2(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char const*, unsigned int, int, bool) (warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

) at cryptlib.cpp:356
warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45418 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c88067 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c88067 in read in psymtab, but not in symtab.)

#1  0xb6c88068 in CryptoPP::StringStore::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) const (warning: (Internal error: pc 0xb6c88067 in read in psymtab, but not in symtab.)

)
    at filters.cpp:1069
warning: (Internal error: pc 0xb6c88067 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c87fd8 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45c43 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45c43 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45c43 in read in psymtab, but not in symtab.)

#2  0xb6c45c44 in CryptoPP::BufferedTransformation::Peek(unsigned char*, unsigned int) const (warning: (Internal error: pc 0xb6c45c43 in read in psymtab, but not in symtab.)

) at cryptlib.h:912
warning: (Internal error: pc 0xb6c45c43 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45b88 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c44f03 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c44f03 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c44f03 in read in psymtab, but not in symtab.)

#3  0xb6c44f04 in CryptoPP::BufferedTransformation::AnyRetrievable() const (warning: (Internal error: pc 0xb6c44f03 in read in psymtab, but not in symtab.)

) at cryptlib.cpp:401
warning: (Internal error: pc 0xb6c44f03 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c44eb4 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45db3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45db3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45db3 in read in psymtab, but not in symtab.)

#4  0xb6c45db4 in CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP::BufferedTransformation&, unsigned int&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (warning: (Internal error: pc 0xb6c45db3 in read in psymtab, but not in symtab.)

) at cryptlib.cpp:506
warning: (Internal error: pc 0xb6c45db3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45cdc in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45f6f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45f6f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45f6f in read in psymtab, but not in symtab.)

#5  0xb6c45f70 in CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::BufferedTransformation&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (warning: (Internal error: pc 0xb6c45f6f in read in psymtab, but not in symtab.)

) at cryptlib.cpp:555
warning: (Internal error: pc 0xb6c45f6f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c45ee8 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5d9a3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5d9a3 in read in psymtab, but not in symtab.)

#6  0xb6c5d9a4 in CryptoPP::StringSource::StringSource(char const*, bool, CryptoPP::BufferedTransformation*) (warning: (Internal error: pc 0xb6c5d9a3 in read in psymtab, but not in symtab.)

) at filters.h:767
warning: (Internal error: pc 0xb6c5d9a3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5d810 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5e46f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5e46f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5e46f in read in psymtab, but not in symtab.)

#7  0xb6c5e470 in CryptoPP::EcRecommendedParameters<CryptoPP::ECP>::NewEC() const (warning: (Internal error: pc 0xb6c5e46f in read in psymtab, but not in symtab.)

) at eccrypto.cpp:94
warning: (Internal error: pc 0xb6c5e46f in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c5e434 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c656c7 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c656c7 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c656c7 in read in psymtab, but not in symtab.)

#8  0xb6c656c8 in CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP>::Initialize(CryptoPP::OID const&) (warning: (Internal error: pc 0xb6c656c7 in read in psymtab, but not in symtab.)

) at eccrypto.cpp:432
warning: (Internal error: pc 0xb6c656c7 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c655cc in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c659cf in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c659cf in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c659cf in read in psymtab, but not in symtab.)

#9  0xb6c659d0 in CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP>::DL_GroupParameters_EC(CryptoPP::OID const&) (warning: (Internal error: pc 0xb6c659cf in read in psymtab, but not in symtab.)

) at eccrypto.h:37
warning: (Internal error: pc 0xb6c659cf in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0xb6c65974 in read in psymtab, but not in symtab.)

#10 0xb6be3a44 in dev::crypto::Secp256k1PP::Secp256k1PP() () at /home/tony/eth/151103215114/src/libweb3core/libdevcrypto/CryptoPP.h:73
#11 0xb6be1124 in __static_initialization_and_destruction_0 () at /home/tony/eth/151103215114/src/libweb3core/libdevcrypto/Common.cpp:53
#12 0xb6be12b4 in _GLOBAL__sub_I_Common.cpp () at /home/tony/eth/151103215114/src/libweb3core/libdevcrypto/Common.cpp:322
#13 0xb6fdf140 in call_init.part.0 () from /lib/ld-linux.so.3
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
warning: (Internal error: pc 0xb6c45424 in read in psymtab, but not in symtab.)

@bobsummerwill
Copy link
Contributor

So that is SUPER early in initialization. Before main() runs, even.
Executing the constructor for what is likely a global variable instance. For a singleton, perhaps?
Any thoughts on how to make the debug symbols match, btw, Tony?

@bobsummerwill
Copy link
Contributor

Yep - the m_params member's constructor is being called implicitly, and I would imagine it's trying to do stuff just way, way too early. Let's find where this singleton or global variable is.

@bobsummerwill
Copy link
Contributor

Line 53 in Common.cpp:

static Secp256k1PP s_secp256k1pp;

@bobsummerwill
Copy link
Contributor

Was ETH_HAVE_SECP256K1 that symbol which you found mis-placed #defines for, Anthony?

@bobsummerwill
Copy link
Contributor

Is it #define on or off for your build? Which code-path are we following? The one into Secp256k1PP, it looks like?

@anthony-cros
Copy link
Author

No Bob, it wasn't that #define

@anthony-cros
Copy link
Author

that being said I didn't build SECP256K1 as it didn't seem required, maybe I need the library in my /lib anyway?

@bobsummerwill
Copy link
Contributor

No, doesn't look that way.
The issue is likely just that the static, global scope variable runs a constructor which tries to do things way too early (like I/O or something). I'll double-check that, and then re-write the C++ for you.

@anthony-cros
Copy link
Author

awesome :)

@bobsummerwill
Copy link
Contributor

A lot of this "pre-main" stuff is very device-specific and undefined. Best practice is not to use global variables. In this case, not because of the scope of visibility, because of the loss of control of execution time for the constructor.

Surprise, surprise. Global variables are bad. Again :-)

@bobsummerwill
Copy link
Contributor

This got fixed by @gavofyork. Please could you close the ticket, @anthony-cros? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants