Cobalt cross-compiliation gives strange result on ARM platform

166 Views Asked by At

We've got problem when cross-compiling cobalt (cobalt.foo) for arm. For mipsel it works great, but when cross-compiling for armv7-a, when optimization flags are set, we got strange result.

Terminal output:

# ./cobalt
dlfree:../../third_party/dlmalloc/dlmalloc.c:4864 - ABORT
Illegal instruction

GDB backtrace:

Program received signal SIGILL, Illegal instruction.
SbSystemBreakIntoDebugger () at ../../starboard/shared/posix/system_break_into_debugger.cc:19
19  ../../starboard/shared/posix/system_break_into_debugger.cc: No such file or directory.
(gdb) bt
#0  SbSystemBreakIntoDebugger () at ../../starboard/shared/posix/system_break_into_debugger.cc:19
#1  0x00d6fa6a in dlfree (mem=mem@entry=0x1aa2ea0) at ../../third_party/dlmalloc/dlmalloc.c:4864
#2  0x00d67924 in SbMemoryFree (memory=memory@entry=0x1aa2ea0)
    at ../../starboard/shared/dlmalloc/memory_free.cc:20
#3  0x00201ac8 in SbMemoryDeallocate (memory=0x1aa2ea0) at ../../starboard/common/memory.cc:96
#4  0x00201ece in operator delete (pointer=<optimized out>) at ../../starboard/common/new.cc:27
#5  0x001fc15a in __gnu_cxx::new_allocator<char>::deallocate (__p=<optimized out>,
    this=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/ext/new_allocator.h:110
#6  std::allocator_traits<std::allocator<char> >::deallocate (__n=<optimized out>,
    __p=<optimized out>, __a=...)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/alloc_traits.h:442
#7  sstarboard/shared/starboard/command_line.cctd::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (
    __size=<optimized out>, this=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/basic_string.h:186
#8  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (
    this=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/basic_string.h:181
#9  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (
    this=<optimized out>, __in_chrg=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/basic_string.h:558
#10 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (
    __pointer=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/stl_construct.h:93
#11 std::_Destroy_aux<false>::__destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (__last=<optimized out>, __first=0xb5a262c0)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/stl_construct.h:103
#12 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*> (
    __last=<optimized out>, __first=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/stl_construct.h:126
#13 std::_Destroy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (__last=0xb5a262d8,
    __first=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/stl_construct.h:151
#14 std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~vector (this=0xbeffef1c, __in_chrg=<optimized out>)
    at /cross/arm-unknown-linux-gnueabihf/include/c++/6.3.0/bits/stl_vector.h:426
#15 starboard::shared::starboard::CommandLine::InitFromArgv (this=this@entry=0xbeffef70,
    argc=argc@entry=1, argv=argv@entry=0xbefff224)
    at ../../starboard/shared/starboard/command_line.cc:121
#16 0x001fc1d0 in starboard::shared::starboard::CommandLine::CommandLine (this=0xbeffef70, argc=1,
---Type <return> to continue, or q <return> to quit---
    argv=0xbefff224) at ../../starboard/shared/starboard/command_line.cc:107
#17 0x001f9624 in starboard::shared::starboard::Application::Run (argv=0xbefff224, argc=1,
    this=0xbeffef98) at ../../starboard/shared/starboard/application.h:166
#18 main (argc=1, argv=0xbefff224) at ../../third_party/starboard/nxgles/main.cc:31

One could be interested what is in command_line.cc:121:

119: void CommandLine::InitFromArgv(int argc,
120:                               const CommandLine::CharType* const* argv) {
121:  StringVector new_argv;
122:  for (int i = 0; i < argc; ++i)
123:    new_argv.push_back(argv[i]);
124:  InitFromArgv(new_argv);
125:}

The SIGILL is generated because __builtin_trap() is called in SbSystemBreakIntoDebugger(). But why vector destructor is called?

This behaviour occures when -O1/-O2/-O3 is set. Behaviour does not occure on mipsel platform. Behaviour does not occure when optimatization flag is set to 0 (-O0).

We are using gcc 6.3.0 and cobalt 20.lts.stable (sha256sum: 1021645ce76f35d61a737da6ee60b0e6831ad922bf43c17697c2d33ea231023e of 20.lts.stable.tar.gz). There are some compilation warnings, but mostly related to unused parameters and deprecations.

Why new_argv destructor is called in a stage, where it should not be called?

Thanks in advance.

0

There are 0 best solutions below