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

Binary built with gcc 5.3.0 will go to crash in the end #24

Closed
YujenHsieh opened this issue Aug 22, 2016 · 6 comments
Closed

Binary built with gcc 5.3.0 will go to crash in the end #24

YujenHsieh opened this issue Aug 22, 2016 · 6 comments

Comments

@YujenHsieh
Copy link

YujenHsieh commented Aug 22, 2016

Hi,
I took the sample code provided by official website and was built with gcc 5.3.0 on Ubuntu 14.04.
The following is the backtrace:

#0 __GI___libc_free (mem=0xb) at malloc.c:2929
#1 0x0000000000405f60 in __gnu_cxx::new_allocatorstd::__detail::_Hash_node_base
::deallocate(std::__detail::_Hash_node_base
*, unsigned long) ()
#2 0x0000000000405914 in std::allocator_traitsstd::allocator<std::__detail::_Hash_node_base* >::deallocate(std::allocatorstd::__detail::_Hash_node_base*&, std::__detail::_Hash_node_base**, unsigned long) ()
#3 0x0000000000405e75 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo>, true> > >::_M_deallocate_buckets(std::__detail::_Hash_node_base**, unsigned long) ()
#4 0x00000000004057ca in std::_Hashtable<fruit::impl::TypeId, std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo>, std::allocator<std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo> >, std::__detail::_Select1st, std::equal_tofruit::impl::TypeId, std::hashfruit::impl::TypeId, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets(std::__detail::_Hash_node_base**, unsigned long) ()
#5 0x00000000004051b6 in std::_Hashtable<fruit::impl::TypeId, std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo>, std::allocator<std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo> >, std::__detail::_Select1st, std::equal_tofruit::impl::TypeId, std::hashfruit::impl::TypeId, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets() ()
#6 0x0000000000404d6e in std::_Hashtable<fruit::impl::TypeId, std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo>, std::allocator<std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo> >, std::__detail::_Select1st, std::equal_tofruit::impl::TypeId, std::hashfruit::impl::TypeId, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable() ()
#7 0x00000000004046b0 in std::unordered_map<fruit::impl::TypeId, fruit::impl::InjectorStorage::BindingCompressionInfo, std::hashfruit::impl::TypeId, std::equal_tofruit::impl::TypeId, std::allocator<std::pair<fruit::impl::TypeId const, fruit::impl::InjectorStorage::BindingCompressionInfo> > >::~unordered_map() ()
#8 0x00000000004046d2 in fruit::impl::NormalizedComponentStorage::~NormalizedComponentStorage() ()
#9 0x0000000000404714 in std::default_deletefruit::impl::NormalizedComponentStorage::operator()(fruit::impl::NormalizedComponentStorage*) const ()
#10 0x0000000000403d35 in std::unique_ptr<fruit::impl::NormalizedComponentStorage, std::default_deletefruit::impl::NormalizedComponentStorage >::~unique_ptr() ()
#11 0x00000000004034b8 in fruit::impl::InjectorStorage::~InjectorStorage() ()
#12 0x00000000004034de in std::default_deletefruit::impl::InjectorStorage::operator()(fruit::impl::InjectorStorage*) const ()
#13 0x0000000000402af1 in std::unique_ptr<fruit::impl::InjectorStorage, std::default_deletefruit::impl::InjectorStorage >::~unique_ptr() ()
#14 0x00000000004023c0 in fruit::Injector::~Injector() ()
#15 0x0000000000401a7c in main ()**

@poletti-marco
Copy link
Contributor

Thanks for the report, I'll take a look this weekend.
In the meantime, could you please provide the exact command that you used to build? Also, what Fruit version you're using? (or are you using git master?)

@YujenHsieh
Copy link
Author

Thanks for your reply. The Fruit version I'm using is 2.0.4-0. I built with "g++-5 -std=c++11 fruit.cpp -lfruit"

@poletti-marco
Copy link
Contributor

The issue looks specific to Ubuntu 14.04.
In Ubuntu 14.04, the following compilers hit the segfault with the Fruit binary packages:

  • Clang 3.5, 3.6, 3.7, 3.8
  • GCC 4.9, GCC 5.0

While GCC 4.8 works.

In Ubuntu 15.10, I've tried the following compilers and they all work:

  • Clang 3.5, 3.6, 3.7, 3.8
  • GCC 5.0

This might be caused by the fact that the Fruit packages are built with GCC (GCC 4.8 for Ubuntu 14.04) and then using them with another compiler is not guaranteed to work (it does usually work though; so I understand that people come to expect this).
I've tried uninstalling the Fruit packages and instead manually building Fruit under Ubuntu 14.04 with each compiler and then compiling the example with the same compiler, and all the following compilers work:

  • GCC 4.8, GCC 4.9, GCC 5.0
  • Clang 3.5, 3.6, 3.7, 3.8

So I would suggest that you do the same. Remember to uninstall the binary packages, as having a mix of manually-built files and binary packages could cause even more trouble.
The instructions for building fruit manually are here.

This might also be due to the fact that the binary packages are built using the openSUSE Build Service, and for Ubuntu 14.04 that uses GCC 4.8.2 instead of a more recent version (Fruit only supports GCC 4.8.3 or later).

Since the prebuilt packages for 14.04 have issues, I've removed them entirely so that other people don't experience the same issues. Sorry for the trouble.

@YujenHsieh
Copy link
Author

It works. Thank you. :)

@qgicup
Copy link

qgicup commented Dec 9, 2017

I cannot compile it on Ubuntu 14.04 with gcc 4.8.4, see below 👍

ization::normalizeBindingsAndAddTo(fruit::impl::FixedSizeVector<fruit::impl::ComponentStorageEntry>&&, fruit::impl::MemoryPool&, const fruit::impl::NormalizedComponentStorage&, fruit::impl::FixedSizeAllocator::FixedSizeAllocatorData&, std::vector<fruit::impl::ComponentStorageEntry, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry> >&, std::unordered_map<fruit::impl::TypeId, fruit::impl::NormalizedMultibindingSet>&)::__lambda40, fruit::impl::BindingNormalization::normalizeBindingsAndAddTo(fruit::impl::FixedSizeVector<fruit::impl::ComponentStorageEntry>&&, fruit::impl::MemoryPool&, const fruit::impl::NormalizedComponentStorage&, fruit::impl::FixedSizeAllocator::FixedSizeAllocatorData&, std::vector<fruit::impl::ComponentStorageEntry, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry> >&, std::unordered_map<fruit::impl::TypeId, fruit::impl::NormalizedMultibindingSet>&)::__lambda41, fruit::impl::BindingNormalization::normalizeBindingsAndAddTo(fruit::impl::FixedSizeVector<fruit::impl::ComponentStorageEntry>&&, fruit::impl::MemoryPool&, const fruit::impl::NormalizedComponentStorage&, fruit::impl::FixedSizeAllocator::FixedSizeAllocatorData&, std::vector<fruit::impl::ComponentStorageEntry, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry> >&, std::unordered_map<fruit::impl::TypeId, fruit::impl::NormalizedMultibindingSet>&)::__lambda42, fruit::impl::BindingNormalization::normalizeBindingsAndAddTo(fruit::impl::FixedSizeVector<fruit::impl::ComponentStorageEntry>&&, fruit::impl::MemoryPool&, const fruit::impl::NormalizedComponentStorage&, fruit::impl::FixedSizeAllocator::FixedSizeAllocatorData&, std::vector<fruit::impl::ComponentStorageEntry, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry> >&, std::unordered_map<fruit::impl::TypeId, fruit::impl::NormalizedMultibindingSet>&)::__lambda43, fruit::impl::BindingNormalization::normalizeBindingsAndAddTo(fruit::impl::FixedSizeVector<fruit::impl::ComponentStorageEntry>&&, fruit::impl::MemoryPool&, const fruit::impl::NormalizedComponentStorage&, fruit::impl::FixedSizeAllocator::FixedSizeAllocatorData&, std::vector<fruit::impl::ComponentStorageEntry, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry> >&, std::unordered_map<fruit::impl::TypeId, fruit::impl::NormalizedMultibindingSet>&)::__lambda44}; fruit::impl::HashMapWithArenaAllocator<fruit::impl::TypeId, fruit::impl::ComponentStorageEntry> = std::unordered_map<fruit::impl::TypeId, fruit::impl::ComponentStorageEntry, std::hash<fruit::impl::TypeId>, std::equal_to<fruit::impl::TypeId>, fruit::impl::ArenaAllocator<std::pair<const fruit::impl::TypeId, fruit::impl::ComponentStorageEntry> > >]’
/home/buddy/work/fruit/fruit-3.1.0/src/binding_normalization.cpp:433:50:   required from here
/usr/include/c++/4.8/bits/hashtable.h:727:6: error: ‘std::_Hashtable<fruit::impl::ComponentStorageEntry::LazyComponentWithNoArgs, fruit::impl::ComponentStorageEntry::LazyComponentWithNoArgs, fruit::impl::ArenaAllocator<fruit::impl::ComponentStorageEntry::LazyComponentWithNoArgs>, std::__detail::_Identity, std::equal_to<fruit::impl::ComponentStorageEntry::LazyComponentWithNoArgs>, fruit::impl::NormalizedComponentStorage::HashLazyComponentWithNoArgs, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::_Node_allocator_type’ has no member named ‘construct’
/home/buddy/work/fruit/fruit-3.1.0/include/fruit/impl/normalized_component_storage/binding_normalization.templates.h:50: confused by earlier errors, bailing out
Preprocessed source stored into /tmp/cc0xnUWM.out file, please attach this to your bugreport.
Traceback (most recent call last):
  File "/usr/share/apport/gcc_ice_hook", line 34, in <module>
    with apport.fileutils.make_report_file(pr) as f:
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 290, in make_report_file
    return open(path, 'xb')
FileExistsError: [Errno 17] File exists: '/var/crash/_usr_lib_gcc_x86_64-linux-gnu_4.8_cc1plus.1000.crash'
make[2]: *** [src/CMakeFiles/fruit.dir/binding_normalization.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/fruit.dir/all] Error 2
make: *** [all] Error 2
buddy@ubuntu:~/work/fruit/fruit-3.1.0/build$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

myuser@ubuntu:~/work/fruit/fruit-3.1.0/build$ 

Also see below my CMake results >

-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test FRUIT_TRIVIAL_SOURCE_COMPILES
-- Performing Test FRUIT_TRIVIAL_SOURCE_COMPILES - Success
-- Performing Test FRUIT_HAS_CLANG_ARBITRARY_OVERLOAD_RESOLUTION_BUG
-- Performing Test FRUIT_HAS_CLANG_ARBITRARY_OVERLOAD_RESOLUTION_BUG - Failed
-- Performing Test FRUIT_HAS_HAS_TRIVIAL_COPY
-- Performing Test FRUIT_HAS_HAS_TRIVIAL_COPY - Success
-- Performing Test FRUIT_HAS_IS_TRIVIALLY_COPYABLE
-- Performing Test FRUIT_HAS_IS_TRIVIALLY_COPYABLE - Failed
-- Performing Test FRUIT_HAS_MAX_ALIGN_T
-- Performing Test FRUIT_HAS_MAX_ALIGN_T - Success
-- Performing Test FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE
-- Performing Test FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE - Failed
-- Performing Test FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE
-- Performing Test FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE - Failed
-- Performing Test FRUIT_HAS_STD_MAX_ALIGN_T
-- Performing Test FRUIT_HAS_STD_MAX_ALIGN_T - Failed
-- Performing Test FRUIT_HAS_TYPEID
-- Performing Test FRUIT_HAS_TYPEID - Success
-- Performing Test FRUIT_HAS_CONSTEXPR_TYPEID
-- Performing Test FRUIT_HAS_CONSTEXPR_TYPEID - Success
-- Performing Test FRUIT_HAS_CXA_DEMANGLE
-- Performing Test FRUIT_HAS_CXA_DEMANGLE - Success
-- Performing Test FRUIT_HAS_ALWAYS_INLINE_ATTRIBUTE
-- Performing Test FRUIT_HAS_ALWAYS_INLINE_ATTRIBUTE - Success
-- Performing Test FRUIT_HAS_FORCEINLINE
-- Performing Test FRUIT_HAS_FORCEINLINE - Failed
-- Performing Test FRUIT_HAS_ATTRIBUTE_DEPRECATED
-- Performing Test FRUIT_HAS_ATTRIBUTE_DEPRECATED - Success
-- Performing Test FRUIT_HAS_GCC_ATTRIBUTE_DEPRECATED
-- Performing Test FRUIT_HAS_GCC_ATTRIBUTE_DEPRECATED - Success
-- Performing Test FRUIT_HAS_DECLSPEC_DEPRECATED
-- Performing Test FRUIT_HAS_DECLSPEC_DEPRECATED - Failed
-- Performing Test FRUIT_HAS_MSVC_ASSUME
-- Performing Test FRUIT_HAS_MSVC_ASSUME - Failed
-- Performing Test FRUIT_HAS_BUILTIN_UNREACHABLE
-- Performing Test FRUIT_HAS_BUILTIN_UNREACHABLE - Success
-- Configuring done
-- Generating done

It only worked to compile Fruit 2.1, but not 3++ versions

@poletti-marco
Copy link
Contributor

It only worked to compile Fruit 2.1, but not 3++ versions

@qgicup: Yes, 3.x doesn't work with GCC<5.0 (and from your logs it's clear that you're using GCC 4.8.4).
See https://github.com/google/fruit/wiki/install#dependencies for more details on supported compilers.
Since you're using Ubuntu 14.04, the distribution-provided GCC is quite old; however you can install a newer one from this PPA: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test , and then use that to build Fruit.

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

3 participants