• 崩溃
(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 == 0if (__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>voidbasic_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 typetypedef _Alloc allocator_type;/// The allocated typetypedef 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析构的时候崩溃

string 析构崩溃 assign相关推荐

  1. c++ string详解 assign

    assign方法可以理解为先将原字符串清空,然后赋予新的值作替换. 返回类型为 string类型的引用.其常用的重载也有下列几种: a. string& assign ( const stri ...

  2. String中的assign函数

    string &assign(const char *s);用c类型字符串s赋值 string &assign(const char *s,int n);用c字符串s开始的n个字符赋值 ...

  3. C++ string assign()赋值常用方法

    C++ string assign()赋值常用方法 函数assign()常用在给string类变量赋值. 常用方法有: 1,直接用另一个字符串赋值. 如str2.assign(str1);即用str1 ...

  4. C++ string assign和append的常用方法

    C++ string assign()赋值常用方法 函数assign()常用在给string类变量赋值. 常用方法有: 1,直接用另一个字符串赋值. 如str2.assign(str1);即用str1 ...

  5. string::assign

    从string类型变量或const char * 中读取部分字符串到string变量中: 赋值(assign) 语法: basic_string &assign( const basic_st ...

  6. C++知识点19——使用C++标准库(再谈string——string的初始化、赋值、添加、删除、访问)

    1.string的构造函数 string();//默认构造函数,默认初始化时调用 string (const string& str);//拷贝构造函数,拷贝初始化时调用 string (si ...

  7. string来存放二进制数据

    在操作mysql数据库类型blob数据时,因为blob是二进制数据,将其存放时要注意,可以使用string来存储数据,然后放入数据库中,特别是在用protobuf序列化后 代码如下: #include ...

  8. 【C++】41. std::copy和assign的用法

    对于std::copy的用法,可以参考 https://blog.csdn.net/a_ran/article/details/17385911,我这里直接介绍对于std::vector来说std:: ...

  9. string与char*的转换(转载)

    //string --> const char string str2ch: str2ch.c_str(); //============================= //string - ...

最新文章

  1. 下一代汽车的核心竞争力到底是什么?
  2. PTP NTP kernel 驱动讲解 (未完待续)
  3. 【C语言探索之旅】 第一部分第六课:条件表达式
  4. Pipenv: Python包管理神器
  5. Git复习(十一)之常见命令用法
  6. 进程和线程(通信方式)、调度算法(6种)
  7. 网络摄像头1 mjpg-streamer使用方法
  8. JAVA实验报告九异常处理_JAVA实验报告_Java异常处理
  9. 冒泡排序与快速排序(java实现)
  10. java使用Encoding导什么包_String getEncoding()
  11. 年薪 37 万+,挪威科技大学(NTNU)招募博士,利用 ML 和 AI 进行钢桥结构健康监测和损伤检测...
  12. P2617 Dynamic Rankings
  13. azure云数据库_Azure SQL数据库地理复制
  14. Interesting Finds: 2008.04.18
  15. python 构建建模无标度网络
  16. Android API下载与使用
  17. Windows系统下使用维基百科中文语料训练Word2Vec词向量
  18. 淘客APP开发定制系统推荐
  19. LDO:低压差线性稳压芯片
  20. Outlook 2007对于不同(Gmail.Sina.Sohu.126.163.Yahoo.Hotmail)Email账号设置

热门文章

  1. antd表格显示分页怎么取消_新买手机号码打电话显示骚扰推销怎么解除取消?...
  2. IDEA中下方git的提交记录上有黄、绿、紫色标记的意思
  3. jnz和djnz_djnz(单片机djnz指令的功能)
  4. 单组学的多变量分析| 2.稀疏偏最小二乘判别分析(sPLS-DA)
  5. 反向比例运算电路微分关系_电气必备20个经典电路,老电工必看!
  6. linux生产文本处理掌握这些就够了:awk,gawk,sed,grep,sort
  7. MetaCoMET----核心微生物组分析在线工具
  8. python交换机ssh巡检_python自动巡检H3C交换机
  9. 职称计算机加分,软著评职称的加分规则
  10. 浙江大学 PTA 递归实现顺序输出整数