Skip to content

Segmentation fault with -march=native #36

@Luthaf

Description

@Luthaf

OS: Ubuntu 18.04 LTS
Compiler: GCC 7.4.0 (7.4.0-1ubuntu1~18.04.1)
CPU: Intel(R) Core(TM) i5-4460S CPU @ 2.90GHz

Compiling the code with -march=native segfaults in the functions dealing with endianness. To reproduce:

cd mmtf-cpp
mkdir build && cd build
cmake -DBUILD_TEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-march=native' ..
make && ctest

Here is the corresponding LLDB session

(lldb) target create "./tests/mmtf_tests"
Current executable set to './tests/mmtf_tests' (x86_64).
(lldb) r
Process 29356 launched: './tests/mmtf_tests' (x86_64)
Process 29356 stopped
* thread #1, name = 'mmtf_tests', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x00005555555bd210 mmtf_tests`mmtf::BinaryDecoder::decodeFromBytes_(std::vector<int, std::allocator<int> >&) [inlined] __bswap_32(__bsx=<unavailable>) at byteswap.h:47
   44  	static __inline unsigned int
   45  	__bswap_32 (unsigned int __bsx)
   46  	{
-> 47  	  return __builtin_bswap32 (__bsx);
   48  	}
   49  	# elif __GNUC__ >= 2
   50  	#  if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__	      \
(lldb) bt
* thread #1, name = 'mmtf_tests', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x00005555555bd210 mmtf_tests`mmtf::BinaryDecoder::decodeFromBytes_(std::vector<int, std::allocator<int> >&) [inlined] __bswap_32(__bsx=<unavailable>) at byteswap.h:47
    frame #1: 0x00005555555bd210 mmtf_tests`mmtf::BinaryDecoder::decodeFromBytes_(std::vector<int, std::allocator<int> >&) [inlined] assignBigendian4(src=<unavailable>, dst=<unavailable>) at binary_decoder.hpp:124
    frame #2: 0x00005555555bd210 mmtf_tests`mmtf::BinaryDecoder::decodeFromBytes_(std::vector<int, std::allocator<int> >&) at binary_decoder.hpp:151
    frame #3: 0x00005555555bd10d mmtf_tests`mmtf::BinaryDecoder::decodeFromBytes_(this=0x0000555555858601, output=size=52) at binary_decoder.hpp:440
    frame #4: 0x00005555555bfde5 mmtf_tests`void mmtf::BinaryDecoder::decode<std::vector<int, std::allocator<int> > >(this=0x00007fffffffc520, output=size=52) at binary_decoder.hpp:304
    frame #5: 0x00005555555c0109 mmtf_tests`void mmtf::MapDecoder::decode<std::vector<int, std::allocator<int> > >(this=0x00007fffffffc880, key="bondAtomList", required=<unavailable>, target=size=52) const at map_decoder.hpp:196
    frame #6: 0x00005555555e77e3 mmtf_tests`mmtf::impl::decodeFromMapDecoder(data=0x00007fffffffccc0, md=0x00007fffffffc880) at msgpack_decoders.hpp:55
    frame #7: 0x00005555555e8315 mmtf_tests`mmtf::decodeFromFile(mmtf::StructureData&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) [inlined] mmtf::decodeFromMapDecoder(md=<unavailable>, data=<unavailable>) at decoder.hpp:103
    frame #8: 0x00005555555e830a mmtf_tests`mmtf::decodeFromFile(data=0x00007fffffffccc0, filename=<unavailable>) at decoder.hpp:123
    frame #9: 0x00005555555a0c3e mmtf_tests`::____C_A_T_C_H____T_E_S_T____0() at mmtf_tests.cpp:47
    frame #10: 0x000055555556bd5e mmtf_tests`Catch::RunContext::invokeActiveTestCase() [inlined] Catch::TestInvokerAsFunction::invoke(this=<unavailable>) const at catch.hpp:9918
    frame #11: 0x000055555556bd5b mmtf_tests`Catch::RunContext::invokeActiveTestCase() [inlined] Catch::TestCase::invoke(this=<unavailable>) const at catch.hpp:9819
    frame #12: 0x000055555556bd3e mmtf_tests`Catch::RunContext::invokeActiveTestCase(this=0x00007fffffffdd60) at catch.hpp:8701
    frame #13: 0x0000555555578b50 mmtf_tests`Catch::RunContext::runCurrentTest(this=0x00007fffffffdd60, redirectedCout="\x90����, redirectedCerr="\xb0����) at catch.hpp:8675
    frame #14: 0x0000555555593641 mmtf_tests`Catch::RunContext::runTest(this=0x00007fffffffdd60, testCase=<unavailable>) at catch.hpp:8464
    frame #15: 0x0000555555593dc6 mmtf_tests`Catch::(anonymous namespace)::runTests(config=std::__shared_ptr<Catch::Config, 4>::element_type @ 0x00005555558426a0) at catch.hpp:9006
    frame #16: 0x00005555555954e1 mmtf_tests`Catch::Session::runInternal(this=0x00007fffffffe0b0) at catch.hpp:9193
    frame #17: 0x00005555555955ca mmtf_tests`Catch::Session::run(this=0x00007fffffffe0b0) at catch.hpp:9147
    frame #18: 0x0000555555564823 mmtf_tests`main at catch.hpp:9115
    frame #19: 0x000055555556481b mmtf_tests`main
    frame #20: 0x0000555555564814 mmtf_tests`main(argc=<unavailable>, argv=0x00007fffffffe308) at catch.hpp:12496
    frame #21: 0x00007ffff706fb97 libc.so.6`__libc_start_main(main=(mmtf_tests`main at catch.hpp:12493), argc=1, argv=0x00007fffffffe308, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe2f8) at libc-start.c:310
    frame #22: 0x0000555555565caa mmtf_tests`_start + 42

I have no idea what is going on here =/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions