Bug 13025 - Segmentation fault when linking mozilla-central with icf on android target
Summary: Segmentation fault when linking mozilla-central with icf on android target
Status: RESOLVED WORKSFORME
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 13:40 UTC by Mike Hommey
Modified: 2012-02-26 15:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Hommey 2011-07-25 13:40:33 UTC
The build environment is the following:
- All the toolchain except binutils is from the android NDK r4c with mozilla modifications (See build env on https://wiki.mozilla.org/index.php?title=User:Blassey/Notes/Android&oldid=280941 )
- Binutils is 2.21.1 built with the following options:
  CC=/tools/gcc-4.5/bin/gcc CXX=/tools/gcc-4.5/bin/g++ ../binutils-2.21.1/configure --prefix=/tmp/android-ndk-r4c/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86 --target=arm-eabi --host=i386-linux-gnu --build=i386-linux-gnu --disable-nls --prefix=/tmp/android-ndk-r4c/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86 --with-sysroot=/tmp/android-ndk-r4c/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/sysroot --program-transform-name=s,^,arm-eabi-, --disable-shared --enable-gold=default
(which are more or less the options used when building stock NDK, except for --enable-gold)
- mozconfig is the following:
 OBJDIR=objdir-android
 mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/$OBJDIR
 ac_add_options --with-android-ndk="/tmp/android-ndk-r4c"
 ac_add_options --with-android-sdk="/tmp/android-sdk-linux_x86/platforms/android-8"
 ac_add_options --enable-application=mobile
 ac_add_options --target=arm-android-eabi
 ac_add_options --with-endian=little
 ac_add_options --disable-tests
 mk_add_options MOZ_MAKE_FLAGS=-j12
 export LDFLAGS=-Wl,--icf=safe

gold segfaults when linking with the following stacktrace:
#0  0x557378e7 in memcpy () from /lib/libc.so.6
#1  0x5562a3a9 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*, unsigned int) () from /usr/lib/libstdc++.so.6
#2  0x08108159 in gold::get_section_contents (first_iteration=true, secn=..., section_num=1, 
    num_tracked_relocs=0xffff92a0, symtab=<value optimized out>, kept_section_id=<value optimized out>, 
    section_contents=<value optimized out>) at ../../binutils-2.21.1/gold/icf.cc:517
#3  0x08109152 in match_sections (this=0xffffc370, input_objects=0xffffc4b0, symtab=0xffffc200)
    at ../../binutils-2.21.1/gold/icf.cc:596
#4  gold::Icf::find_identical_sections (this=0xffffc370, input_objects=0xffffc4b0, symtab=0xffffc200)
    at ../../binutils-2.21.1/gold/icf.cc:753
#5  0x08106622 in gold::queue_middle_tasks (options=..., task=0x85d38f0, input_objects=0xffffc4b0, symtab=0xffffc200, 
    layout=0xffffc00c, workqueue=0xffffc53c, mapfile=0x0) at ../../binutils-2.21.1/gold/gold.cc:347
#6  0x08106a3e in gold::Middle_runner::run (this=0x82f1ec0, workqueue=0xffffc53c, task=0x85d38f0)
    at ../../binutils-2.21.1/gold/gold.cc:125
#7  0x08106a7f in gold::Task_function::run (this=0x85d38f0, workqueue=0xffffc53c)
    at ../../binutils-2.21.1/gold/workqueue.h:178
#8  0x081f6284 in gold::Workqueue::find_and_run_task (this=0xffffc53c, thread_number=0)
    at ../../binutils-2.21.1/gold/workqueue.cc:319
#9  0x081f65dc in gold::Workqueue::process (this=0xffffc53c, thread_number=0)
    at ../../binutils-2.21.1/gold/workqueue.cc:495
#10 0x0804beb6 in main (argc=84, argv=0xffffc674) at ../../binutils-2.21.1/gold/main.cc:247

bt full for the first frames:
#0  0x557378e7 in memcpy () from /lib/libc.so.6
No symbol table info available.
#1  0x5562a3a9 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*, unsigned int) () from /usr/lib/libstdc++.so.6
No symbol table info available.
#2  0x08108159 in gold::get_section_contents (first_iteration=true, secn=..., section_num=1, 
    num_tracked_relocs=0xffff92a0, symtab=<value optimized out>, kept_section_id=<value optimized out>, 
    section_contents=<value optimized out>) at ../../binutils-2.21.1/gold/icf.cc:517
        contents = 0x55d13c60 <Address 0x55d13c60 out of bounds>
        plen = 4
        icf_reloc_buffer = {static npos = <optimized out>, 
          _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x82acb9c ""}}
#3  0x08109152 in match_sections (this=0xffffc370, input_objects=0xffffc4b0, symtab=0xffffc200)
    at ../../binutils-2.21.1/gold/icf.cc:596
        num_relocs = 0
        cksum = <value optimized out>
        secn = {first = 0x830c8e8, second = 27}
        this_secn_contents = {static npos = <optimized out>, 
          _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x82acb9c ""}}
        this_secn_contents_array = <value optimized out>
        i = <value optimized out>
        section_cksum = {<std::tr1::__unordered_multimap<unsigned int, unsigned int, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> >, false>> = {<std::tr1::_Hashtable<unsigned int, std::pair<unsigned int const, unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> >, std::_Select1st<std::pair<unsigned int const, unsigned int> >, std::equal_to<unsigned int>, std::tr1::hash<unsigned int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, false>> = {<std::tr1::__detail::_Rehash_base<std::tr1::__detail::_Prime_rehash_policy, std::tr1::_Hashtable<unsigned int, std::pair<unsigned int const, unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> >, std::_Select1st<std::pair<unsigned int const, unsigned int> >, std::equal_to<unsigned int>, std::tr1::hash<unsigned int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, false> >> = {<No data fields>}, <std::tr1::__detail::_Hash_code_base<unsigned int, std::pair<unsigned int const, unsigned int>, std::_Select1st<std::pair<unsigned int const, unsigned int> >, std::equal_to<unsigned int>, std::tr1::hash<unsigned int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, false>> = {
                _M_extract = {<std::unary_function<std::pair<unsigned int const, unsigned int>, unsigned int const>> = {<No data fields>}, <No data fields>}, 
                _M_eq = {<std::binary_function<unsigned int, unsigned int, bool>> = {<No data fields>}, <No data fields>}, _M_h1 = {<std::unary_function<unsigned int, unsigned int>> = {<No data fields>}, <No data fields>}, 
                _M_h2 = {<No data fields>}}, <std::tr1::__detail::_Map_base<unsigned int, std::pair<unsigned int const, unsigned int>, std::_Select1st<std::pair<unsigned int const, unsigned int> >, false, std::tr1::_Hashtable<unsigned int, std::pair<unsigned int const, unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> >, std::_Select1st<std::pair<unsigned int const, unsigned int> >, std::equal_to<unsigned int>, std::tr1::hash<unsigned int>, std::tr1::__detail::_Mod_range_hashing, std::tr1::__detail::_Default_ranged_hash, std::tr1::__detail::_Prime_rehash_policy, false, false, false> >> = {<No data fields>}, 
              _M_node_allocator = {<__gnu_cxx::new_allocator<std::tr1::__detail::_Hash_node<std::pair<unsigned int const, unsigned int>, false> >> = {<No data fields>}, <No data fields>}, _M_buckets = 0x90adc40, _M_bucket_count = 11, 
              _M_element_count = 0, _M_rehash_policy = {_M_max_load_factor = 1, _M_growth_factor = 2, 
                _M_next_resize = 11}}, <No data fields>}, <No data fields>}
        converged = <value optimized out>
        full_section_contents = {<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
            _M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0x919e760, _M_finish = 0x919e768, _M_end_of_storage = 0x919e768}}, <No data fields>}
#4  gold::Icf::find_identical_sections (this=0xffffc370, input_objects=0xffffc4b0, symtab=0xffffc200)
    at ../../binutils-2.21.1/gold/icf.cc:753
        num_tracked_relocs = {<std::_Vector_base<unsigned int, std::allocator<unsigned int> >> = {
            _M_impl = {<std::allocator<unsigned int>> = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No data fields>}, _M_start = 0x910a588, _M_finish = 0x910d088, _M_end_of_storage = 0x910e588}}, <No data fields>}
        section_contents = {<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
            _M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0x90a8ce0, _M_finish = 0x90ab7e0, _M_end_of_storage = 0x90acce0}}, <No data fields>}
        converged = <value optimized out>
        section_num = 2752
        is_secn_or_group_unique = {<std::_Bvector_base<std::allocator<bool> >> = {
            _M_impl = {<std::allocator<unsigned long>> = {<__gnu_cxx::new_allocator<unsigned long>> = {<No data fields>}, <No data fields>}, 
              _M_start = {<std::_Bit_iterator_base> = {<std::iterator<std::random_access_iterator_tag, bool, int, bool*, bool&>> = {<No data fields>}, _M_p = 0x908e220, _M_offset = 0}, <No data fields>}, 
              _M_finish = {<std::_Bit_iterator_base> = {<std::iterator<std::random_access_iterator_tag, bool, int, bool*, bool&>> = {<No data fields>}, _M_p = 0x908e378, _M_offset = 0}, <No data fields>}, 
              _M_end_of_storage = 0x908e420}}, <No data fields>}
        num_iterations = 2
        max_iterations = 2
Comment 1 Mike Hommey 2011-07-25 14:13:15 UTC
Whatever Debian provides as version 2.21.53.20110720 doesn't have this problem... (with or without the debian patches) so it might actually be fixed on trunk.
Comment 2 Mike Hommey 2011-07-25 14:21:50 UTC
(In reply to comment #1)
> Whatever Debian provides as version 2.21.53.20110720 doesn't have this
> problem... (with or without the debian patches) so it might actually be fixed
> on trunk.

Actually, while it doesn't crash, it looks like it does nothing :(
Comment 3 Mike Hommey 2011-07-25 14:32:43 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Whatever Debian provides as version 2.21.53.20110720 doesn't have this
> > problem... (with or without the debian patches) so it might actually be fixed
> > on trunk.
> 
> Actually, while it doesn't crash, it looks like it does nothing :(

Please disregard both comments, i wasn't building with -ffunction-sections this time.
Comment 4 Mike Hommey 2011-07-25 15:03:14 UTC
In the end, both comments still apply, once I build with -ffunction-sections.
Comment 5 Mike Hommey 2011-07-25 15:08:48 UTC
(In reply to comment #4)
> In the end, both comments still apply, once I build with -ffunction-sections.

*Sigh*, this is getting embarassing. I had -Wl,--icf=safe twice on my command line and only removed one. So, in the end, it does work. I'll double check if the crash is gone on current HEAD, though.
Comment 6 Mike Hommey 2011-07-25 18:41:16 UTC
I can confirm this is fixed on HEAD.
Comment 7 Bill Gianopoulos (:WG9s) 2012-02-26 15:59:32 UTC
I suspect this was fixed by bug 10708.