在共享指针超出范围之后,C ++ 11中的析构函数崩溃

时间:2014-11-12 03:19:28

标签: c++11 memory-leaks gdb valgrind shared-ptr

我在Destructor中面临崩溃。下面是从地图中删除

后载体的对象创建和对象的析构函数的代码片段

以下是代码段

/ *对象创建* /

shared_ptr<ICarrier> Factory::MakeCarrier(int carrierId, int beamId)
{
    return make_shared < Carrier > (carrierId, beamId);
}

/ * Dest * /

shared_ptr<ICarrier> pCarrier = nullptr;

for (auto carrierIterator = mCarrierIdToCarrierMap.cbegin();
    carrierIterator != mCarrierIdToCarrierMap.cend();)
{
    carrierIterator = mCarrierIdToCarrierMap.erase(carrierIterator);
}

virtual ~ICarrier()
{
}

Carrier::Carrier(int carrierId, int beamId)
{
    // Create new logger level by appending beam ID.
    string newLoggerLevel = "rgw.beam." + to_string(beamId) + ".carrier."+ to_string(carrierId);
    // Retrieve logger for the newly created logger level
    mLogger = log4cxx::Logger::getLogger(newLoggerLevel);
    LOG4CXX_INFO(mLogger, " Carrier created with Id :" << carrierId);
    mPmcIp = 0;
}

Carrier::~Carrier()
{
}

GDB o / p

Breakpoint 2, Carrier::~Carrier (this=0xccc478, __in_chrg=<value optimized out>) at Carrier.cpp:24

    24      Carrier::~Carrier()

    (gdb) bt

    #0  Carrier::~Carrier (this=0xccc478, __in_chrg=<value optimized out>) at Carrier.cpp:24

    #1  0x00000000004469de in Carrier::~Carrier (this=0xccc478, __in_chrg=<value optimized out>) at Carrier.cpp:27

    #2  0x0000000000422f5d in __gnu_cxx::new_allocator<Carrier>::destroy<Carrier> (this=0xccc470, __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/ext/new_allocator.h:124

    #3  0x0000000000422e21 in std::allocator_traits<std::allocator<Carrier> >::_S_destroy<Carrier> (__a=..., __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/alloc_traits.h:281

    #4  0x0000000000422cf9 in std::allocator_traits<std::allocator<Carrier> >::destroy<Carrier> (__a=..., __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/alloc_traits.h:405

    #5  0x0000000000422a81 in std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0xccc460) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:407

    #6  0x000000000040aee0 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0xccc460) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:144

    #7  0x000000000040acd0 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator= (this=0x7ffffffe25f8, __r=...) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:565

    #8  0x0000000000419f27 in std::__shared_ptr<ICarrier, (__gnu_cxx::_Lock_policy)2>::operator= (this=0x7ffffffe25f0) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:728

    #9  0x0000000000419f51 in std::shared_ptr<ICarrier>::operator= (this=0x7ffffffe25f0) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr.h:93

    #10 0x00000000004154c6 in Beam::DeleteAllCarriers (this=0xccca58) at Beam.cpp:383

    #11 0x00000000004151eb in Beam::OnDeleting (this=0xccca58, tlliBvciVector=...) at Beam.cpp:352

    #12 0x0000000000428134 in PBSC::DeleteBeamsWithTraversedFlagSet (this=0xcc8080) at PBSC.cpp:587

    #13 0x0000000000428ceb in PBSC::OnCarrierMapping (this=0xcc8080, pCarrierMapping=...) at PBSC.cpp:682

    #14 0x0000000000409615 in pbsc::RMS::HandleRMSCarrierMappingMsg (this=0xccb970, recvdCarrierMapping=...) at RMS.cpp:133

    #15 0x0000000000408f10 in pbsc::RMS::HandleMessage (this=0xccb970, portNumber=21015, pRecvMsg=0x7ffffffea470 "\n\002\b\003\f\003\204", sizeOfMessageRead=4) at RMS.cpp:55

    #16 0x0000000000481630 in inframe::ModuleManager::ProcessRxMessage (this=0xcc9280, msgBuf=0x7ffffffea470 "\n\002\b\003\f\003\204", numOfBytes=@0x7fffffff9ea8, portNumber=@0x7ffffffe69c4, remoteAddr=...) at ModuleManager.cpp:1054

    #17 0x000000000047fdb0 in inframe::ModuleManager::RecvAndForwardMessage (this=0xcc9280, portNumber=21015) at ModuleManager.cpp:612

    #18 0x0000000000451f9f in pbsc::PBSCApp::ActOnInterrupt (this=0x7fffffffdb90, tick=83118159) at PBSCApp.cpp:101

    #19 0x00000000004798a1 in inframe::AppTask::ReadInterrupt (this=0x7fffffffdb90) at AppTask.cpp:263

    #20 0x0000000000455d60 in pbsc::PBSCAppMain (argc=7, argv=0x7fffffffe1c8) at PBSCApp.cpp:699

    #21 0x00000000004550b4 in main (argc=7, argv=0x7fffffffe1c8) at PBSCApp.cpp:550

    (gdb) n

崩溃:

*检测到glibc * / home / nverma / Test / PBSC_1 / bin / pbsc_1:free():指针无效:0x0000000000ccc478 ***

 Backtrace:

/lib64/libc.so.6[0x3cb1c76166]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x4469ea]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x422f5d]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x422e21]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x422cf9]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x422a81]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x40aee0]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x40acd0]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x419f27]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x419f51]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x4154c6]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x4151eb]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x428134]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x428ceb]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x409615]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x408f10]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x481630]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x47fdb0]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x451f9f]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x4798a1]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x455d60]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x4550b4]

/lib64/libc.so.6(__libc_start_main+0xfd)[0x3cb1c1ed1d]

/home/nverma/Test/PBSC_1/bin/pbsc_1[0x408489]

======= Memory map: ========

00400000-005f8000 r-xp 00000000 fd:02 540387                             /home/nverma/Test/PBSC_1/bin/pbsc_1

007f8000-007f9000 rw-p 001f8000 fd:02 540387                             /home/nverma/Test/PBSC_1/bin/pbsc_1

007f9000-00cd7000 rw-p 00000000 00:00 0                                  [heap]

33a0800000-33a081d000 r-xp 00000000 fd:00 1310819                        /lib64/libselinux.so.1

33a081d000-33a0a1c000 ---p 0001d000 fd:00 1310819                        /lib64/libselinux.so.1

33a0a1c000-33a0a1d000 r--p 0001c000 fd:00 1310819                        /lib64/libselinux.so.1

33a0a1d000-33a0a1e000 rw-p 0001d000 fd:00 1310819                        /lib64/libselinux.so.1

33a0a1e000-33a0a1f000 rw-p 00000000 00:00 0

33a5c00000-33a5c04000 r-xp 00000000 fd:00 1327246                        /lib64/libuuid.so.1.3.0

33a5c04000-33a5e03000 ---p 00004000 fd:00 1327246                        /lib64/libuuid.so.1.3.0

33a5e03000-33a5e04000 rw-p 00003000 fd:00 1327246                        /lib64/libuuid.so.1.3.0

33a6000000-33a6027000 r-xp 00000000 fd:00 2756506                        /usr/lib64/libssh2.so.1.0.1

33a6027000-33a6226000 ---p 00027000 fd:00 2756506                        /usr/lib64/libssh2.so.1.0.1

33a6226000-33a6227000 rw-p 00026000 fd:00 2756506                        /usr/lib64/libssh2.so.1.0.1

33a6227000-33a6228000 rw-p 00000000 00:00 0

33a6400000-33a6403000 r-xp 00000000 fd:00 1327243                        /lib64/libcom_err.so.2.1

33a6403000-33a6602000 ---p 00003000 fd:00 1327243                        /lib64/libcom_err.so.2.1

33a6602000-33a6603000 r--p 00002000 fd:00 1327243                        /lib64/libcom_err.so.2.1

33a6603000-33a6604000 rw-p 00003000 fd:00 1327243                        /lib64/libcom_err.so.2.1

33a6800000-33a680a000 r-xp 00000000 fd:00 1310815                        /lib64/libkrb5support.so.0.1

33a680a000-33a6a09000 ---p 0000a000 fd:00 1310815                        /lib64/libkrb5support.so.0.1

33a6a09000-33a6a0a000 r--p 00009000 fd:00 1310815                        /lib64/libkrb5support.so.0.1

33a6a0a000-33a6a0b000 rw-p 0000a000 fd:00 1310815                        /lib64/libkrb5support.so.0.1

33a6c00000-33a6c29000 r-xp 00000000 fd:00 1327242                        /lib64/libk5crypto.so.3.1

33a6c29000-33a6e29000 ---p 00029000 fd:00 1327242                        /lib64/libk5crypto.so.3.1

33a6e29000-33a6e2a000 r--p 00029000 fd:00 1327242                        /lib64/libk5crypto.so.3.1

33a6e2a000-33a6e2b000 rw-p 0002a000 fd:00 1327242                        /lib64/libk5crypto.so.3.1

33a6e2b000-33a6e2c000 rw-p 00000000 00:00 0

33a7000000-33a70db000 r-xp 00000000 fd:00 1327244                        /lib64/libkrb5.so.3.3

33a70db000-33a72da000 ---p 000db000 fd:00 1327244                        /lib64/libkrb5.so.3.3

33a72da000-33a72e4000 r--p 000da000 fd:00 1327244                        /lib64/libkrb5.so.3.3

33a72e4000-33a72e6000 rw-p 000e4000 fd:00 1327244                        /lib64/libkrb5.so.3.3

33a7400000-33a7441000 r-xp 00000000 fd:00 1327245                        /lib64/libgssapi_krb5.so.2.2

33a7441000-33a7641000 ---p 00041000 fd:00 1327245                        /lib64/libgssapi_krb5.so.2.2

33a7641000-33a7642000 r--p 00041000 fd:00 1327245                        /lib64/libgssapi_krb5.so.2.2

33a7642000-33a7644000 rw-p 00042000 fd:00 1327245                        /lib64/libgssapi_krb5.so.2.2

33a7800000-33a7861000 r-xp 00000000 fd:00 2764023                        /usr/lib64/libssl.so.1.0.1e

33a7861000-33a7a60000 ---p 00061000 fd:00 2764023                        /usr/lib64/libssl.so.1.0.1e

33a7a60000-33a7a64000 r--p 00060000 fd:00 2764023                        /usr/lib64/libssl.so.1.0.1e

33a7a64000-33a7a6b000 rw-p 00064000 fd:00 2764023                        /usr/lib64/libssl.so.1.0.1e

33a8800000-33a8851000 r-xp 00000000 fd:00 2767573                        /usr/lib64/libcurl.so.4.1.1

33a8851000-33a8a50000 ---p 00051000 fd:00 2767573                        /usr/lib64/libcurl.so.4.1.1

33a8a50000-33a8a53000 rw-p 00050000 fd:00 2767573                        /usr/lib64/libcurl.so.4.1.1

3585000000-35851b5000 r-xp 00000000 fd:00 2761539                        /usr/lib64/libcrypto.so.1.0.1e

35851b5000-35853b5000 ---p 001b5000 fd:00 2761539                        /usr/lib64/libcrypto.so.1.0.1e

35853b5000-35853d0000 r--p 001b5000 fd:00 2761539                        /usr/lib64/libcrypto.so.1.0.1e

35853d0000-35853dc000 rw-p 001d0000 fd:00 2761539                        /usr/lib64/libcrypto.so.1.0.1e

35853dc000-35853e0000 rw-p 00000000 00:00 0

3cb1800000-3cb1820000 r-xp 00000000 fd:00 1327173                        /lib64/ld-2.12.so

3cb1a1f000-3cb1a20000 r--p 0001f000 fd:00 1327173                        /lib64/ld-2.12.so

3cb1a20000-3cb1a21000 rw-p 00020000 fd:00 1327173                        /lib64/ld-2.12.so

3cb1a21000-3cb1a22000 rw-p 00000000 00:00 0

3cb1c00000-3cb1d8b000 r-xp 00000000 fd:00 1327174                        /lib64/libc-2.12.so

3cb1d8b000-3cb1f8a000 ---p 0018b000 fd:00 1327174                        /lib64/libc-2.12.so

3cb1f8a000-3cb1f8e000 r--p 0018a000 fd:00 1327174                        /lib64/libc-2.12.so

3cb1f8e000-3cb1f8f000 rw-p 0018e000 fd:00 1327174                        /lib64/libc-2.12.so

编程接收信号SIGABRT,已中止。

来自/lib64/libc.so.6的raise()中的

0x0000003cb1c32925

(gdb) bt

#0  0x0000003cb1c32925 in raise () from /lib64/libc.so.6

#1  0x0000003cb1c34105 in abort () from /lib64/libc.so.6

#2  0x0000003cb1c70837 in __libc_message () from /lib64/libc.so.6

#3  0x0000003cb1c76166 in malloc_printerr () from /lib64/libc.so.6

#4  0x00000000004469ea in Carrier::~Carrier (this=0xccc478, __in_chrg=<value optimized out>) at Carrier.cpp:27

#5  0x0000000000422f5d in __gnu_cxx::new_allocator<Carrier>::destroy<Carrier> (this=0xccc470, __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/ext/new_allocator.h:124

#6  0x0000000000422e21 in std::allocator_traits<std::allocator<Carrier> >::_S_destroy<Carrier> (__a=..., __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/alloc_traits.h:281

#7  0x0000000000422cf9 in std::allocator_traits<std::allocator<Carrier> >::destroy<Carrier> (__a=..., __p=0xccc478) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/alloc_traits.h:405

#8  0x0000000000422a81 in std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0xccc460) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:407

#9  0x000000000040aee0 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0xccc460) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:144

#10 0x000000000040acd0 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator= (this=0x7ffffffe25f8, __r=...) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:565

#11 0x0000000000419f27 in std::__shared_ptr<ICarrier, (__gnu_cxx::_Lock_policy)2>::operator= (this=0x7ffffffe25f0) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr_base.h:728

#12 0x0000000000419f51 in std::shared_ptr<ICarrier>::operator= (this=0x7ffffffe25f0) at /usr/local/tools/gcc/4.8.2/include/c++/4.8.2/bits/shared_ptr.h:93

#13 0x00000000004154c6 in Beam::DeleteAllCarriers (this=0xccca58) at Beam.cpp:383

#14 0x00000000004151eb in Beam::OnDeleting (this=0xccca58, tlliBvciVector=...) at Beam.cpp:352

#15 0x0000000000428134 in PBSC::DeleteBeamsWithTraversedFlagSet (this=0xcc8080) at PBSC.cpp:587

#16 0x0000000000428ceb in PBSC::OnCarrierMapping (this=0xcc8080, pCarrierMapping=...) at PBSC.cpp:682

#17 0x0000000000409615 in pbsc::RMS::HandleRMSCarrierMappingMsg (this=0xccb970, recvdCarrierMapping=...) at RMS.cpp:133

#18 0x0000000000408f10 in pbsc::RMS::HandleMessage (this=0xccb970, portNumber=21015, pRecvMsg=0x7ffffffea470 "\n\002\b\003\f\003\204", sizeOfMessageRead=4) at RMS.cpp:55

#19 0x0000000000481630 in inframe::ModuleManager::ProcessRxMessage (this=0xcc9280, msgBuf=0x7ffffffea470 "\n\002\b\003\f\003\204", numOfBytes=@0x7fffffff9ea8, portNumber=@0x7ffffffe69c4, remoteAddr=...) at ModuleManager.cpp:1054

#20 0x000000000047fdb0 in inframe::ModuleManager::RecvAndForwardMessage (this=0xcc9280, portNumber=21015) at ModuleManager.cpp:612

#21 0x0000000000451f9f in pbsc::PBSCApp::ActOnInterrupt (this=0x7fffffffdb90, tick=83118159) at PBSCApp.cpp:101

#22 0x00000000004798a1 in inframe::AppTask::ReadInterrupt (this=0x7fffffffdb90) at AppTask.cpp:263

#23 0x0000000000455d60 in pbsc::PBSCAppMain (argc=7, argv=0x7fffffffe1c8) at PBSCApp.cpp:699

#24 0x00000000004550b4 in main (argc=7, argv=0x7fffffffe1c8) at PBSCApp.cpp:550

Valgrind的

==32508== Memcheck, a memory error detector
==32508== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==32508== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==32508== Command: ./pbsc_1 1 3145740 3178509 193 45.48.25.21 1

==32508== Syscall param socketcall.recvfrom(fromlen_in) points to uninitialised byte(s)
==32508==    at 0x3CB280EBD3: ??? (in /lib64/libpthread-2.12.so)
==32508==    by 0x479B18: inframe::AppTask::ReadInterrupt() (AppTask.cpp:234)
==32508==    by 0x45617F: pbsc::PBSCAppMain(int, char**) (PBSCApp.cpp:699)
==32508==    by 0x4554D3: main (PBSCApp.cpp:550)
==32508==  Address 0x7fefff99c is on thread 1's stack
==32508==  Uninitialised value was created by a stack allocation
==32508==    at 0x479AA0: inframe::AppTask::ReadInterrupt() (AppTask.cpp:216)

==32508== 
==32508== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==32508==    at 0x3CB280EDB3: ??? (in /lib64/libpthread-2.12.so)
==32508==    by 0x482301: inframe::Module::SendMessage(std::string const*, int) (Module.cpp:94)
==32508==    by 0x40E272: pbsc::EMS::SendEMSCompStatusMsg(CompUnicastMetaMessage&) (EMS.cpp:378)
==32508==    by 0x429BF9: PBSC::SendEMSComponentStatusMessage() const (PBSC.cpp:800)
==32508==    by 0x4244EF: PBSC::OnSgsnStatusChange(ESgsnStatus) (PBSC.cpp:130)
==32508==    by 0x432FCC: SGSN::DecodeMessageFromStack(char*) (SGSN.cpp:447)
==32508==    by 0x43703C: SGSN::HandleMessage(unsigned short, char const*, int) (SGSN.cpp:810)
==32508==    by 0x481A4F: inframe::ModuleManager::ProcessRxMessage(char*, int&, unsigned short&, sockaddr_in&) (ModuleManager.cpp:1054)
==32508==    by 0x4801CF: inframe::ModuleManager::RecvAndForwardMessage(unsigned short) (ModuleManager.cpp:612)
==32508==    by 0x4523E0: pbsc::PBSCApp::ActOnInterrupt(unsigned long) (PBSCApp.cpp:102)
==32508==    by 0x479CC0: inframe::AppTask::ReadInterrupt() (AppTask.cpp:263)
==32508==    by 0x45617F: pbsc::PBSCAppMain(int, char**) (PBSCApp.cpp:699)
==32508==  Address 0x5fc4baa is 170 bytes inside a block of size 176 alloc'd
==32508==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)
==32508==    by 0x5813CA8: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (new_allocator.h:104)
==32508==    by 0x581487A: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (basic_string.tcc:629)
==32508==    by 0x5814913: std::string::reserve(unsigned long) (basic_string.tcc:510)
==32508==    by 0x5814CD5: std::string::append(unsigned long, char) (basic_string.tcc:288)
==32508==    by 0x4C6455E: google::protobuf::MessageLite::AppendPartialToString(std::string*) const (basic_string.h:667)
==32508==    by 0x40E172: pbsc::EMS::SendEMSCompStatusMsg(CompUnicastMetaMessage&) (EMS.cpp:375)
==32508==    by 0x429BF9: PBSC::SendEMSComponentStatusMessage() const (PBSC.cpp:800)
==32508==    by 0x4244EF: PBSC::OnSgsnStatusChange(ESgsnStatus) (PBSC.cpp:130)
==32508==    by 0x432FCC: SGSN::DecodeMessageFromStack(char*) (SGSN.cpp:447)
==32508==    by 0x43703C: SGSN::HandleMessage(unsigned short, char const*, int) (SGSN.cpp:810)
==32508==    by 0x481A4F: inframe::ModuleManager::ProcessRxMessage(char*, int&, unsigned short&, sockaddr_in&) (ModuleManager.cpp:1054)
==32508==  Uninitialised value was created by a heap allocation
==32508==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)
==32508==    by 0x411E42: pbsc::EMSManager::CreateModule() const (EMSManager.cpp:67)
==32508==    by 0x47E386: inframe::ModuleManager::Associate(unsigned int) (ModuleManager.cpp:133)
==32508==    by 0x45281B: pbsc::PBSCApp::InitializeEMSManager(unsigned int, unsigned int, unsigned short) const (PBSCApp.cpp:164)
==32508==    by 0x455FC3: pbsc::PBSCAppMain(int, char**) (PBSCApp.cpp:675)
==32508==    by 0x4554D3: main (PBSCApp.cpp:550)
==32508== 

==32508== Invalid free() / delete / delete[] / realloc()
==32508==    at 0x4A05FD6: operator delete(void*) (vg_replace_malloc.c:480)
==32508==    by 0x446E07: Carrier::~Carrier() (Carrier.cpp:33)
==32508==    by 0x4231D0: void __gnu_cxx::new_allocator<Carrier>::destroy<Carrier>(Carrier*) (new_allocator.h:124)
==32508==    by 0x423094: std::enable_if<std::allocator_traits<std::allocator<Carrier> >::__destroy_helper<Carrier>::value, void>::type std::allocator_traits<std::allocator<Carrier> >::_S_destroy<Carrier>(std::allocator<Carrier>&, Carrier*) (alloc_traits.h:281)
==32508==    by 0x422F6C: void std::allocator_traits<std::allocator<Carrier> >::destroy<Carrier>(std::allocator<Carrier>&, Carrier*) (alloc_traits.h:405)
==32508==    by 0x422CF4: std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:407)
==32508==    by 0x40B04F: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:144)
==32508==    by 0x40AE3F: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_count<(__gnu_cxx::_Lock_policy)2> const&) (shared_ptr_base.h:565)
==32508==    by 0x41A154: std::__shared_ptr<ICarrier, (__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_ptr<ICarrier, (__gnu_cxx::_Lock_policy)2> const&) (shared_ptr_base.h:728)
==32508==    by 0x41A17E: std::shared_ptr<ICarrier>::operator=(std::shared_ptr<ICarrier> const&) (shared_ptr.h:93)
==32508==    by 0x4156A0: Beam::DeleteAllCarriers() (Beam.cpp:386)
==32508==    by 0x4153C2: Beam::OnDeleting(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >&) (Beam.cpp:355)
==32508==  Address 0x5fe21a8 is 24 bytes inside a block of size 64 alloc'd
==32508==    at 0x4A075BC: operator new(unsigned long) (vg_replace_malloc.c:298)
==32508==    by 0x421995: __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:104)
==32508==    by 0x4215D9: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<Carrier, std::allocator<Carrier>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:351)
==32508==    by 0x4211AF: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Carrier, std::allocator<Carrier>, int&, int&>(std::_Sp_make_shared_tag, Carrier*, std::allocator<Carrier> const&, int&, int&) (shared_ptr_base.h:499)
==32508==    by 0x420DDA: std::__shared_ptr<Carrier, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Carrier>, int&, int&>(std::_Sp_make_shared_tag, std::allocator<Carrier> const&, int&, int&) (shared_ptr_base.h:957)
==32508==    by 0x420B97: std::shared_ptr<Carrier>::shared_ptr<std::allocator<Carrier>, int&, int&>(std::_Sp_make_shared_tag, std::allocator<Carrier> const&, int&, int&) (shared_ptr.h:316)
==32508==    by 0x4208B5: std::shared_ptr<Carrier> std::allocate_shared<Carrier, std::allocator<Carrier>, int&, int&>(std::allocator<Carrier> const&, int&, int&) (shared_ptr.h:598)
==32508==    by 0x420576: _ZSt11make_sharedI7CarrierIRiS1_EESt10shared_ptrIT_EDpOT0_ (shared_ptr.h:614)
==32508==    by 0x4200FE: Factory::MakeCarrier(int, int) (Factory.cpp:43)
==32508==    by 0x415178: Beam::AddCarrier(int, int) (Beam.cpp:318)
==32508==    by 0x414FB4: Beam::Update(rgw::common::BeamInfo const&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >&) (Beam.cpp:294)
==32508==    by 0x428D91: PBSC::OnCarrierMapping(rgw::common::CarrierMapping const&) (PBSC.cpp:662)
==32508== 

1 个答案:

答案 0 :(得分:0)

删除所有析构函数,似乎都不需要。