public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58822] New: Segfault when calling make_shared
@ 2013-10-21  8:12 michi at triodia dot com
  2013-10-21  9:09 ` [Bug libstdc++/58822] " paolo.carlini at oracle dot com
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-21  8:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

            Bug ID: 58822
           Summary: Segfault when calling make_shared
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michi at triodia dot com

I have a constructor calling make_shared to pass a shared_ptr to a base class.

InvalidArgumentException::InvalidArgumentException(string const& reason)
//    : Exception(shared_ptr<ExceptionImplBase>(new ExceptionImplBase(this,
"unity::InvalidArgumentException", reason)))
    : Exception(make_shared<ExceptionImplBase>(this,
"unity::InvalidArgumentException", reason))
{
}

When I run this, I get a segfault (stack trace below). If I create the
shared_ptr explicitly (see the commented-out line) instead of calling
make_shared, things work fine. For what it's worth, if I use clang 4.3 instead,
things work as expected in both cases.

I would have thought that, no matter what else might be going on, a call to
make_shared<T>(args) should always be equivalent to a call to shared_ptr<T>(new
T(args)), but that's not what I'm seeing.

I tried reproducing this with a simple example, but no joy. Before I spend a
lot of time trying to pare this down to a stand-alone test case (this is in a
large code base), are there any known issues that could be causing this? gdb
stack trace below, as well as output from valgrind.

Thanks,

Michi.

#0  0x000000000041c986 in
__gnu_cxx::new_allocator<unity::ExceptionImplBase>::construct<unity::ExceptionImplBase<unity::InvalidArgumentException*
const, char const (&) [32], std::string const&> > (this=0x7fffffffd6ef,
__p=0x665388)
    at /usr/include/c++/4.8/ext/new_allocator.h:120
#1  0x000000000041c93d in
std::allocator_traits<std::allocator<unity::ExceptionImplBase>
>::_S_construct<unity::ExceptionImplBase<unity::InvalidArgumentException*
const, char const (&) [32], std::string const&>
>(std::allocator<unity::ExceptionImplBase>&,
std::allocator_traits<std::allocator<unity::ExceptionImplBase>
>::__construct_helper*,
(unity::ExceptionImplBase<unity::InvalidArgumentException* const, char const
(&) [32], std::string const&>&&)...) (__a=..., 
    __p=0x665388) at /usr/include/c++/4.8/bits/alloc_traits.h:254
#2  0x000000000041c8d2 in
std::allocator_traits<std::allocator<unity::ExceptionImplBase>
>::construct<unity::ExceptionImplBase<unity::InvalidArgumentException* const,
char const (&) [32], std::string const&>
>(std::allocator<unity::ExceptionImplBase>&,
unity::ExceptionImplBase<unity::InvalidArgumentException* const, char const (&)
[32], std::string const&>*,
(unity::ExceptionImplBase<unity::InvalidArgumentException* const, char const
(&) [32], std::string const&>&&)...) (
    __a=..., __p=0x665388) at /usr/include/c++/4.8/bits/alloc_traits.h:393
#3  0x000000000041c7ec in
std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (this=0x665370, __a=...) at
/usr/include/c++/4.8/bits/shared_ptr_base.h:399
#4  0x000000000041c681 in
__gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2>
>::construct<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&> > (this=0x7fffffffd827, 
    __p=0x665370) at /usr/include/c++/4.8/ext/new_allocator.h:120
#5  0x000000000041c599 in
std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2> >
>::_S_construct<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&> >(std::allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2> >&,
std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2> >
>::__construct_helper*, (std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>&&)...) (__a=..., __p=0x665370)
    at /usr/include/c++/4.8/bits/alloc_traits.h:254
#6  0x000000000041c488 in
std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2> >
>::construct<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&> >(std::allocator<std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, (__gnu_cxx::_Lock_policy)2> >&,
std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>*, (std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2><std::allocator<unity::ExceptionImplBase> const,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>&&)...) (__a=..., __p=0x665370) at
/usr/include/c++/4.8/bits/alloc_traits.h:393
#7  0x000000000041c33f in
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string const&>(std::_Sp_make_shared_tag,
unity::ExceptionImplBase*, std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (this=0x7fffffffda28, __a=...)
    at /usr/include/c++/4.8/bits/shared_ptr_base.h:522
#8  0x000000000041c16f in std::__shared_ptr<unity::ExceptionImplBase,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (this=0x7fffffffda20, __tag=..., __a=...)
    at /usr/include/c++/4.8/bits/shared_ptr_base.h:986
#9  0x000000000041bdd8 in
std::shared_ptr<unity::ExceptionImplBase>::shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (this=0x7fffffffda20, __tag=..., __a=...) at
/usr/include/c++/4.8/bits/shared_ptr.h:316
#10 0x000000000041b8aa in std::allocate_shared<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (__a=...)
    at /usr/include/c++/4.8/bits/shared_ptr.h:598
#11 0x000000000041b539 in std::make_shared<unity::ExceptionImplBase,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) ()
    at /usr/include/c++/4.8/bits/shared_ptr.h:614
#12 0x0000000000419283 in
unity::InvalidArgumentException::InvalidArgumentException (this=0x6652a0,
reason=..., 
    __in_chrg=<optimised out>, __vtt_parm=<optimised out>)
    at /home/michi/src/exception-fix/src/unity/UnityExceptions.cpp:29
#13 0x0000000000413748 in b () at
/home/michi/src/exception-fix/test/gtest/unity/Exceptions_test.cpp:98


Valgrind:
==24622== Use of uninitialised value of size 8
==24622==    at 0x41C986:
_ZN9__gnu_cxx13new_allocatorIN5unity17ExceptionImplBaseEE9constructIS2_IKPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C93C:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE12_S_constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS3_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS2_PSF_DpOSG_
(alloc_traits.h:254)
==24622==    by 0x41C8D1:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE9constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS2_PT_DpOSD_
(alloc_traits.h:393)
==24622==    by 0x41C7EB:
std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:399)
==24622==    by 0x41C680:
_ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS3_ELNS_12_Lock_policyE2EEE9constructIS6_IKS4_KPNS2_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C598:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE12_S_constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS8_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS7_PSL_DpOSM_
(alloc_traits.h:254)
==24622==    by 0x41C487:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE9constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS7_PT_DpOSJ_
(alloc_traits.h:393)
==24622==    by 0x41C33E:
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string const&>(std::_Sp_make_shared_tag,
unity::ExceptionImplBase*, std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:522)
==24622==    by 0x41C16E: std::__shared_ptr<unity::ExceptionImplBase,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr_base.h:986)
==24622==    by 0x41BDD7:
std::shared_ptr<unity::ExceptionImplBase>::shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:316)
==24622==    by 0x41B8A9: std::shared_ptr<unity::ExceptionImplBase>
std::allocate_shared<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr.h:598)
==24622==    by 0x41B538: std::shared_ptr<unity::ExceptionImplBase>
std::make_shared<unity::ExceptionImplBase, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:614)
==24622== 
==24622== Invalid read of size 8
==24622==    at 0x41C986:
_ZN9__gnu_cxx13new_allocatorIN5unity17ExceptionImplBaseEE9constructIS2_IKPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C93C:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE12_S_constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS3_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS2_PSF_DpOSG_
(alloc_traits.h:254)
==24622==    by 0x41C8D1:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE9constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS2_PT_DpOSD_
(alloc_traits.h:393)
==24622==    by 0x41C7EB:
std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:399)
==24622==    by 0x41C680:
_ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS3_ELNS_12_Lock_policyE2EEE9constructIS6_IKS4_KPNS2_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C598:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE12_S_constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS8_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS7_PSL_DpOSM_
(alloc_traits.h:254)
==24622==    by 0x41C487:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE9constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS7_PT_DpOSJ_
(alloc_traits.h:393)
==24622==    by 0x41C33E:
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string const&>(std::_Sp_make_shared_tag,
unity::ExceptionImplBase*, std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:522)
==24622==    by 0x41C16E: std::__shared_ptr<unity::ExceptionImplBase,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr_base.h:986)
==24622==    by 0x41BDD7:
std::shared_ptr<unity::ExceptionImplBase>::shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:316)
==24622==    by 0x41B8A9: std::shared_ptr<unity::ExceptionImplBase>
std::allocate_shared<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr.h:598)
==24622==    by 0x41B538: std::shared_ptr<unity::ExceptionImplBase>
std::make_shared<unity::ExceptionImplBase, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:614)
==24622==  Address 0xffffffffffffffe8 is not stack'd, malloc'd or (recently)
free'd
==24622== 
==24622== 
==24622== Process terminating with default action of signal 11 (SIGSEGV)
==24622==  Access not within mapped region at address 0xFFFFFFFFFFFFFFE8
==24622==    at 0x41C986:
_ZN9__gnu_cxx13new_allocatorIN5unity17ExceptionImplBaseEE9constructIS2_IKPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C93C:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE12_S_constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS3_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS2_PSF_DpOSG_
(alloc_traits.h:254)
==24622==    by 0x41C8D1:
_ZNSt16allocator_traitsISaIN5unity17ExceptionImplBaseEEE9constructIS1_IKPNS0_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS2_PT_DpOSD_
(alloc_traits.h:393)
==24622==    by 0x41C7EB:
std::_Sp_counted_ptr_inplace<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>,
(__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:399)
==24622==    by 0x41C680:
_ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS3_ELNS_12_Lock_policyE2EEE9constructIS6_IKS4_KPNS2_24InvalidArgumentExceptionERA32_KcRKSsEEEvPT_DpOT0_
(in /home/michi/src/exception-fix/build/test/gtest/unity/Exceptions_test)
==24622==    by 0x41C598:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE12_S_constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEENSt9enable_ifIXsrNS8_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS7_PSL_DpOSM_
(alloc_traits.h:254)
==24622==    by 0x41C487:
_ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN5unity17ExceptionImplBaseESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE9constructIS6_IKS3_KPNS1_24InvalidArgumentExceptionERA32_KcRKSsEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS7_PT_DpOSJ_
(alloc_traits.h:393)
==24622==    by 0x41C33E:
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string const&>(std::_Sp_make_shared_tag,
unity::ExceptionImplBase*, std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr_base.h:522)
==24622==    by 0x41C16E: std::__shared_ptr<unity::ExceptionImplBase,
(__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr_base.h:986)
==24622==    by 0x41BDD7:
std::shared_ptr<unity::ExceptionImplBase>::shared_ptr<std::allocator<unity::ExceptionImplBase>,
unity::InvalidArgumentException* const, char const (&) [32], std::string
const&>(std::_Sp_make_shared_tag, std::allocator<unity::ExceptionImplBase>
const&, unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:316)
==24622==    by 0x41B8A9: std::shared_ptr<unity::ExceptionImplBase>
std::allocate_shared<unity::ExceptionImplBase,
std::allocator<unity::ExceptionImplBase>, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(std::allocator<unity::ExceptionImplBase> const&,
unity::InvalidArgumentException* const&&, char const (&) [32], std::string
const&) (shared_ptr.h:598)
==24622==    by 0x41B538: std::shared_ptr<unity::ExceptionImplBase>
std::make_shared<unity::ExceptionImplBase, unity::InvalidArgumentException*
const, char const (&) [32], std::string
const&>(unity::InvalidArgumentException* const&&, char const (&) [32],
std::string const&) (shared_ptr.h:614)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
@ 2013-10-21  9:09 ` paolo.carlini at oracle dot com
  2013-10-22  2:20 ` michi at triodia dot com
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-21  9:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-10-21
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In any case, please provide a self-contained (minimized, please) testcase, it's
a requirement for our Bugzilla bug reports. Thanks.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
  2013-10-21  9:09 ` [Bug libstdc++/58822] " paolo.carlini at oracle dot com
@ 2013-10-22  2:20 ` michi at triodia dot com
  2013-10-22  2:22 ` michi at triodia dot com
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-22  2:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #2 from Michi Henning <michi at triodia dot com> ---
Created attachment 31066
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31066&action=edit
Stand-alone test case


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
  2013-10-21  9:09 ` [Bug libstdc++/58822] " paolo.carlini at oracle dot com
  2013-10-22  2:20 ` michi at triodia dot com
@ 2013-10-22  2:22 ` michi at triodia dot com
  2013-10-22  8:29 ` michi at triodia dot com
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-22  2:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #3 from Michi Henning <michi at triodia dot com> ---
To build and run the code in the tarball:

cd exception-fix/build
cmake ..
make
make test

The problem is caused by the call to make_shared on line 33 of
UnityExceptions.h.

If you comment out the initializer and enable the commented-out initializer,
the segfault goes away.

The segfault with make_shared also goes away if the virtual inheritance from
Exception is replaced with non-virtual inheritance.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (2 preceding siblings ...)
  2013-10-22  2:22 ` michi at triodia dot com
@ 2013-10-22  8:29 ` michi at triodia dot com
  2013-10-22  8:40 ` paolo.carlini at oracle dot com
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-22  8:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #4 from Michi Henning <michi at triodia dot com> ---
Hmmm... Trying this on a different machine, it works perfectly. It looks like
there is something screwed up with the gcc installation on the machine where
I'm seeing this.

So, please hold off putting any work into this. I'll close or update as soon as
I've worked out what's going on.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (3 preceding siblings ...)
  2013-10-22  8:29 ` michi at triodia dot com
@ 2013-10-22  8:40 ` paolo.carlini at oracle dot com
  2013-10-22  8:49 ` michi at triodia dot com
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22  8:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks. Note that, in general, tarballs, using make, etc, is not fine:
http://gcc.gnu.org/bugs/#report Please, just a single preprocessed .ii file.
I'm keeping the bug open for now.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (4 preceding siblings ...)
  2013-10-22  8:40 ` paolo.carlini at oracle dot com
@ 2013-10-22  8:49 ` michi at triodia dot com
  2013-10-22  8:50 ` paolo.carlini at oracle dot com
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-22  8:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #6 from Michi Henning <michi at triodia dot com> ---
My apologies, I'm a newbie in the gcc bug world. Will try to mend my ways!

Cheers,

Michi.

PS: I'll work on this more tomorrow, but I'm pretty sure that gcc is not to
blame. There is some stale header kicking around that is responsible this or
some such. Will update the bug and close it once I find the culprit.


On 22/10/2013, at 18:40 , "paolo.carlini at oracle dot com"
<gcc-bugzilla@gcc.gnu.org> wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822
> 
> --- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
> Thanks. Note that, in general, tarballs, using make, etc, is not fine:
> http://gcc.gnu.org/bugs/#report Please, just a single preprocessed .ii file.
> I'm keeping the bug open for now.
> 
> -- 
> You are receiving this mail because:
> You reported the bug.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (5 preceding siblings ...)
  2013-10-22  8:49 ` michi at triodia dot com
@ 2013-10-22  8:50 ` paolo.carlini at oracle dot com
  2013-10-23  3:13 ` michi at triodia dot com
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22  8:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Ok, thanks!


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (6 preceding siblings ...)
  2013-10-22  8:50 ` paolo.carlini at oracle dot com
@ 2013-10-23  3:13 ` michi at triodia dot com
  2013-10-23  4:58 ` michi at triodia dot com
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  3:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Michi Henning <michi at triodia dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #8 from Michi Henning <michi at triodia dot com> ---
OK, the problem was almost certainly caused by an SVN version of libc++. (Not
completely sure about this but, after completely removing all remnants of clang
on my machine things started working again.)

Sorry for the noise I created!


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (7 preceding siblings ...)
  2013-10-23  3:13 ` michi at triodia dot com
@ 2013-10-23  4:58 ` michi at triodia dot com
  2013-10-23  4:59 ` michi at triodia dot com
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  4:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Michi Henning <michi at triodia dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #9 from Michi Henning <michi at triodia dot com> ---
Hmmm... I spoke too soon. I made a simple mistake and tried the test case with
the wrong settings.

I can now reproduce this on another machine (one that has never had any clang
component installed). This is with a brand-new installation of gcc
(4.8.1-10ubuntu8) from the Canonical package archives.

gcc reports:

gcc (Ubuntu/Linaro 4.8.10-10ubuntu8) 4.8.1

uname reports:

Linux ubuntu 3.11.0-8-generic #15-Ubuntu SMP Fri Sep 20 04:11:26 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux

I've attached the .ii file, as well as an archive with an even more minimal
test case (one source file, three header files, all trivial).

I'd very much appreciate it if someone could confirm whether this bug is real
or whether I'm seeing ghosts.

Thanks muchly,

Michi.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (8 preceding siblings ...)
  2013-10-23  4:58 ` michi at triodia dot com
@ 2013-10-23  4:59 ` michi at triodia dot com
  2013-10-23  5:02 ` michi at triodia dot com
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  4:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #10 from Michi Henning <michi at triodia dot com> ---
Created attachment 31078
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31078&action=edit
main.ii illustrating the segfault


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (9 preceding siblings ...)
  2013-10-23  4:59 ` michi at triodia dot com
@ 2013-10-23  5:02 ` michi at triodia dot com
  2013-10-23  5:03 ` michi at triodia dot com
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  5:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Michi Henning <michi at triodia dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #31066|0                           |1
        is obsolete|                            |

--- Comment #11 from Michi Henning <michi at triodia dot com> ---
Created attachment 31079
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31079&action=edit
Source code for minimal test case


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (10 preceding siblings ...)
  2013-10-23  5:02 ` michi at triodia dot com
@ 2013-10-23  5:03 ` michi at triodia dot com
  2013-10-23  5:22 ` michi at triodia dot com
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  5:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #12 from Michi Henning <michi at triodia dot com> ---
Output from gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.8.1-10ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (11 preceding siblings ...)
  2013-10-23  5:03 ` michi at triodia dot com
@ 2013-10-23  5:22 ` michi at triodia dot com
  2013-10-23  9:32 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23  5:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #13 from Michi Henning <michi at triodia dot com> ---
Just had a collegue of mine reproduce the problem with the attached archive on
a machine that was installed from the Saucy .iso image, so I think this bug is
real. It's not just something on my machines.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (12 preceding siblings ...)
  2013-10-23  5:22 ` michi at triodia dot com
@ 2013-10-23  9:32 ` paolo.carlini at oracle dot com
  2013-10-23 11:57 ` michi at triodia dot com
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-23  9:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|michi at triodia dot com           |

--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I can reproduce it, but whatever it is, I doubt it's a *library* issue, because
the same preprocessed file compiled by clang or icc doesn't Segfault.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug libstdc++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (13 preceding siblings ...)
  2013-10-23  9:32 ` paolo.carlini at oracle dot com
@ 2013-10-23 11:57 ` michi at triodia dot com
  2013-10-23 12:03 ` [Bug c++/58822] " paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23 11:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #15 from Michi Henning <michi at triodia dot com> ---
OK, glad you are seeing it too. I initially opened this as a library issue
because I thought make_shared is to blame. But maybe not. Should I reassign to
C++?


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (14 preceding siblings ...)
  2013-10-23 11:57 ` michi at triodia dot com
@ 2013-10-23 12:03 ` paolo.carlini at oracle dot com
  2013-10-23 12:04 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-23 12:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++

--- Comment #16 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Let's do that, yes. But I would like to ear from Jon anyway.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (15 preceding siblings ...)
  2013-10-23 12:03 ` [Bug c++/58822] " paolo.carlini at oracle dot com
@ 2013-10-23 12:04 ` paolo.carlini at oracle dot com
  2013-10-23 12:08 ` michi at triodia dot com
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-23 12:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #17 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Also, since apparently this isn't a library issue, it would be nice to figure
out a reduced testcase not including <memory>.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (16 preceding siblings ...)
  2013-10-23 12:04 ` paolo.carlini at oracle dot com
@ 2013-10-23 12:08 ` michi at triodia dot com
  2013-10-23 12:33 ` michi at triodia dot com
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23 12:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #18 from Michi Henning <michi at triodia dot com> ---
Hmmm... That might be difficult because, as soon as I don't use make_shared,
the problem goes away. (With the virtual inheritance in place but a call to
shared_ptr<T>(args), as in the commented-out line in UnityExceptions.h, the
segfault disappears. It also disappears if make_shared is left in place, but
the virtual inheritance is changed to non-virtual inheritance.

So, this appears to be some interaction between make_shared and virtual
inheritance. I think the test case is close to minimal already.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (17 preceding siblings ...)
  2013-10-23 12:08 ` michi at triodia dot com
@ 2013-10-23 12:33 ` michi at triodia dot com
  2013-10-23 12:38 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-10-23 12:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #20 from Michi Henning <michi at triodia dot com> ---
(In reply to Paolo Carlini from comment #19)
> I'm pretty sure it isn't. It's easy to see why: in the testcase are you
> using *all* the facilities provided by std::shared_ptr as standardized? I
> don't think so! Thus just imagine having the class there, and commenting out
> all the member functions you don't use. Likewise for the free functions.
> Also, including <memory> means *a ton* of code which definitely has
> *nothing* to do with std::shared_ptr. Normally, a C++ testcase is less than
> 100 lines without includes. The exceptions are *extremely* rare.

I'm not really sure what else to do here. The code in total only contains
constructors and destructors. Just looking again, I forgot to delete a #include
for <string> in ExceptionImplBase, and I guess I could have deleted the
namespaces as well.

I'm pretty sure that I'm not using anything in shared_ptr that's outside the
standard, and the standard way to get access to shared_ptr is to include
<memory>. If I include something else, I end up in implementation territory,
don't I?

So, what should I do to get the bug report up to scratch? (I've already spent
quite a few hours cutting this down to what it is now from a large project.)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (18 preceding siblings ...)
  2013-10-23 12:33 ` michi at triodia dot com
@ 2013-10-23 12:38 ` paolo.carlini at oracle dot com
  2013-10-23 13:56 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-23 12:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #21 from Paolo Carlini <paolo.carlini at oracle dot com> ---
You could start from the .ii: edit it, delete all the things you don't use. Or
start by removing the inclusion of <memory> and adding to the testcase a
mini-version of std::shared_ptr, with bits copied from <memory>. See what I
mean? For sure, nobody working on C++ front-end bugs wants to see the whole
<memory> included in the testcase (your attachment is 500 KBytes!!) likely will
just put it apart and the issue will remain unfixed for months or even years
(wouldn't be the first time)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (19 preceding siblings ...)
  2013-10-23 12:38 ` paolo.carlini at oracle dot com
@ 2013-10-23 13:56 ` manu at gcc dot gnu.org
  2013-11-11 11:46 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: manu at gcc dot gnu.org @ 2013-10-23 13:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #22 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Michi Henning from comment #20)
> I'm not really sure what else to do here. The code in total only contains
> constructors and destructors. Just looking again, I forgot to delete a
> #include for <string> in ExceptionImplBase, and I guess I could have deleted
> the namespaces as well.
> 
> I'm pretty sure that I'm not using anything in shared_ptr that's outside the
> standard, and the standard way to get access to shared_ptr is to include
> <memory>. If I include something else, I end up in implementation territory,
> don't I?

Some ideas on how to go about reducing testcases are here:
http://gcc.gnu.org/bugs/minimize.html
>From gcc-bugs-return-432555-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 23 13:58:18 2013
Return-Path: <gcc-bugs-return-432555-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16916 invoked by alias); 23 Oct 2013 13:58:17 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16860 invoked by uid 48); 23 Oct 2013 13:58:14 -0000
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58822] Segfault when calling make_shared
Date: Wed, 23 Oct 2013 13:58:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo.carlini at oracle dot com
X-Bugzilla-Status: REOPENED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58822-4-0y5Ofc44aM@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58822-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58822-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01699.txt.bz2
Content-length: 165

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX822

--- Comment #23 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Manuel, I knew we had something.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (20 preceding siblings ...)
  2013-10-23 13:56 ` manu at gcc dot gnu.org
@ 2013-11-11 11:46 ` redi at gcc dot gnu.org
  2013-11-11 12:27 ` michi at triodia dot com
  2013-11-12 23:11 ` vlukas at gmx dot de
  23 siblings, 0 replies; 25+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-11 11:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #24 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Michi Henning from comment #20)
> I'm pretty sure that I'm not using anything in shared_ptr that's outside the
> standard, and the standard way to get access to shared_ptr is to include
> <memory>. If I include something else, I end up in implementation territory,
> don't I?

Yes, but you're trying to report a bug specific to this implementation, not in
the standard.

If you still haven't reduced this I'll do so, but it might have to wait a week
or two.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (21 preceding siblings ...)
  2013-11-11 11:46 ` redi at gcc dot gnu.org
@ 2013-11-11 12:27 ` michi at triodia dot com
  2013-11-12 23:11 ` vlukas at gmx dot de
  23 siblings, 0 replies; 25+ messages in thread
From: michi at triodia dot com @ 2013-11-11 12:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

--- Comment #25 from Michi Henning <michi at triodia dot com> ---
(In reply to Jonathan Wakely from comment #24)
> (In reply to Michi Henning from comment #20)
> > I'm pretty sure that I'm not using anything in shared_ptr that's outside the
> > standard, and the standard way to get access to shared_ptr is to include
> > <memory>. If I include something else, I end up in implementation territory,
> > don't I?
> 
> Yes, but you're trying to report a bug specific to this implementation, not
> in the standard.

Right. As best as I can tell, this is a code generation bug in gcc. Clang
generates code for the same thing that works fine.

> If you still haven't reduced this I'll do so, but it might have to wait a
> week or two.

I'm really time-limited at the moment. I tried creduce, but the latest version
requires an upgrade to Perl, and I haven't gotten around to installing that
yet.

One thing that is really taxing is the difficulty of whittling down the system
headers. I started out with over 25,000 lines of very convoluted template code,
which I have laboriously reduced to around 1300 lines. Of those, a good 800
lines or so are from type_traits, and its exceedingly difficult to reduce that
included code further.

I tried creduce, but it bombs on my machine. I'm told that I have to use the
latest Perl for it to work, but haven't gotten around to installing that yet.

If you care to have a look, I'd appreciate it very much! I'm under too much
pressure at the moment to find the extra cycles to work on this. It's not a
show-stopper right now for me, but it will be in another three weeks from. If
only there were more than 24 hours in a day :-(

Thanks,

Michi.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Bug c++/58822] Segfault when calling make_shared
  2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
                   ` (22 preceding siblings ...)
  2013-11-11 12:27 ` michi at triodia dot com
@ 2013-11-12 23:11 ` vlukas at gmx dot de
  23 siblings, 0 replies; 25+ messages in thread
From: vlukas at gmx dot de @ 2013-11-12 23:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58822

vlukas at gmx dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vlukas at gmx dot de

--- Comment #26 from vlukas at gmx dot de ---
I think the main.ii from 2013-10-23 can be reduced to this:
-----------------------------------------------------------
struct Exception {
  Exception(int) {}
};

template<typename Arg>
int make_shared(Arg arg)
{
  Exception* p = arg; p = p;
  return 0;
}

struct InvalidArgumentException : public virtual Exception
{
 explicit InvalidArgumentException() : Exception(make_shared(this))
 { }

  virtual ~InvalidArgumentException() noexcept {}
};

int main()
{
  throw InvalidArgumentException();
}
----------------------------------------------------------

I believe this violates a restriction of the Standard, namely section 3.8,
paragraph 5, dash 3 (in the N3290 draft or in N3797).

I can reproduce a segmentation fault with both my reduced testcase and the
original main.ii.

Mr. Henning, you could try the following:
In your main.ii on line 24571 substitute the *implicit* cast by an explicit
one, so that the line reads
: Exception(std::make_shared<ExceptionImplBase>(static_cast<Exception*>(this)))

Or replace the forbidden implicit cast by changing line 24556 so that it reads
template<class E> explicit ExceptionImplBase(E const*) {}

Both options fulfill the requirements of the Standard to the letter and on my
system make the segmentation fault go away. Valgrind won't indicated an error
with those modifications either.


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2013-11-12 23:11 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-21  8:12 [Bug libstdc++/58822] New: Segfault when calling make_shared michi at triodia dot com
2013-10-21  9:09 ` [Bug libstdc++/58822] " paolo.carlini at oracle dot com
2013-10-22  2:20 ` michi at triodia dot com
2013-10-22  2:22 ` michi at triodia dot com
2013-10-22  8:29 ` michi at triodia dot com
2013-10-22  8:40 ` paolo.carlini at oracle dot com
2013-10-22  8:49 ` michi at triodia dot com
2013-10-22  8:50 ` paolo.carlini at oracle dot com
2013-10-23  3:13 ` michi at triodia dot com
2013-10-23  4:58 ` michi at triodia dot com
2013-10-23  4:59 ` michi at triodia dot com
2013-10-23  5:02 ` michi at triodia dot com
2013-10-23  5:03 ` michi at triodia dot com
2013-10-23  5:22 ` michi at triodia dot com
2013-10-23  9:32 ` paolo.carlini at oracle dot com
2013-10-23 11:57 ` michi at triodia dot com
2013-10-23 12:03 ` [Bug c++/58822] " paolo.carlini at oracle dot com
2013-10-23 12:04 ` paolo.carlini at oracle dot com
2013-10-23 12:08 ` michi at triodia dot com
2013-10-23 12:33 ` michi at triodia dot com
2013-10-23 12:38 ` paolo.carlini at oracle dot com
2013-10-23 13:56 ` manu at gcc dot gnu.org
2013-11-11 11:46 ` redi at gcc dot gnu.org
2013-11-11 12:27 ` michi at triodia dot com
2013-11-12 23:11 ` vlukas at gmx dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).