• 崩溃
(gdb) bt
#0 0x00007f5a4eb24418 in _int_free () from /lib64/libc.so.6
#1 0x00007f5a4f440c03 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() () from /lib64/libstdc++.so.6
#2 0x000000000042ad93 in CEndpoint::FileMD5 (this=0x7f59d80010c0, event=..., scan_list=std::list = {...}, info=...) at ../Endpoint.cpp:322

...

#7 0x00007f5a50eeae25 in start_thread () from /lib64/libpthread.so.0
#8 0x00007f5a4eba034d in clone () from /lib64/libc.so.6
(gdb) f 2
#2 0x000000000042ad93 in CEndpoint::FileMD5 (this=0x7f59d80010c0, event=..., scan_list=std::list = {...}, info=...) at ../Endpoint.cpp:322
(gdb) p uploadJSON
$1 = "{\"FilePath\":\"c:\\\\windows\\\\ey87mb9scd\\\\x86\\\\secopatcher.dll\",\"MD5\":\"e0f0683bb8cfd4413eccd777034e6a20\"}"
  • 代码

析构中报错

/**
* @brief Destroy the string instance.
*/
~basic_string() _GLIBCXX_NOEXCEPT
{ _M_rep()->_M_dispose(this->get_allocator()); }

_M_dispose

void
_M_dispose(const _Alloc& __a)
{
#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
if (__builtin_expect(this != &_S_empty_rep(), false))
#endif
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
-1) <= 0)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
_M_destroy(__a);
}
}
} // XXX MT

_M_destroy 在basic_string.tcc定义

template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::_Rep::
_M_destroy(const _Alloc& __a) throw ()
{
const size_type __size = sizeof(_Rep_base) +
(this->_M_capacity + 1) * sizeof(_CharT);
_Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
}

_Alloc deallocate 释放内存

/**
* @brief Uniform interface to all allocator types.
* @ingroup allocators
*/
template<typename _Alloc>
struct allocator_traits
{
/// The allocator type
typedef _Alloc allocator_type;
/// The allocated type
typedef typename _Alloc::value_type value_type;

/**
* @brief Deallocate memory.
* @param __a An allocator.
* @param __p Pointer to the memory to deallocate.
* @param __n The number of objects space was allocated for.
*
* Calls <tt> a.deallocate(p, n) </tt>
*/
static void deallocate(_Alloc& __a, pointer __p, size_type __n)
{ __a.deallocate(__p, __n); }


...

}

代码中是用assign来 str.assign(str2),str2 是通过rapidjson GetString()获得,    basic_string.h头文件内容中声明basic_string& assign(const basic_string& __str);

#include <ext/atomicity.h>
#include <debug/debug.h>
#if __cplusplus >= 201103L
#include <initializer_list>
#endif

/**
* @brief Set value to contents of another string.
* @param __str Source string to use.
* @return Reference to this string.
*/
basic_string&
assign(const basic_string& __str);

basic_string.h 中 #include <debug/debug.h>, 在debug.h中找到assign定义

basic_string&
assign(const basic_string& __x)
{
_Base::assign(__x);
this->_M_invalidate_all();
return *this;
}

str析构的时候崩溃