首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C++构造函数中的损坏

C++构造函数中的损坏
EN

Stack Overflow用户
提问于 2014-08-15 01:35:11
回答 1查看 261关注 0票数 0

我正面临着构造器中的损坏。有人能帮帮我吗?

代码语言:javascript
复制
    2873            int rc = _db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
    (gdb) p selectConstruct
    $1 = {distinct = false, colsToBeSelected = {cols = {<std::_Vector_base<dbCol,     std::allocator<dbCol> >> = {_M_impl = {<std::allocator<dbCol>> = {<__gnu_cxx::new_allocator<dbCol>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, tableName = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x3dd36f32d8 ""}}, where = {whereExprs = {<std::_Vector_base<whereExpr, std::allocator<whereExpr> >> = {_M_impl = {<std::allocator<whereExpr>> = {<__gnu_cxx::new_allocator<whereExpr>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, ops = {<std::_Vector_base<adjoinOperator, std::allocator<adjoinOperator> >> = {_M_impl = {<std::allocator<adjoinOperator>> = {<__gnu_cxx::new_allocator<adjoinOperator>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, namespaceCounts = {<std::_Vector_base<unsigned int, std::allocator<unsigned int> >> = {_M_impl = {<std::allocator<unsigned int>> = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, useAsON = false}, groupBy = {cols = {<std::_Vector_base<dbCol, std::allocator<dbCol> >> = {_M_impl = {<std::allocator<dbCol>> = {<__gnu_cxx::new_allocator<dbCol>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, orders = {orders = {<std::_Vector_base<orderingTerm, std::allocator<orderingTerm> >> = {_M_impl = {<std::allocator<orderingTerm>> = {<__gnu_cxx::new_allocator<orderingTerm>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, limit = -1}
   (gdb) stepi
    0x00007ffff0df9b49      2873            int rc = _db-   >fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
   (gdb) stepi
   0x00007ffff0df9b50      2873            int rc = _db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
   (gdb) stepi
   0x00007ffff0df9b53      2873            int rc = _db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
  (gdb) stepi
   0x00007ffff0df9b5b      2873            int rc = _db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
   (gdb) stepi
   0x00007ffff0df9b5e      2873            int rc = _db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct, HandleCustomSqlQueryResponse, (void*)&holder);
   (gdb) stepi
    0x00007ffff0da8000 in simpleSelectConstruct::simpleSelectConstruct () from   /opt/OV/lbin/OpsAgt/libDMLSegment.so
   (gdb) stepi
   simpleSelectConstruct::simpleSelectConstruct (this=0x7fffdbffdbb0) at /home/parakkal/COLLABNET_11.10_NEW/hpsw-oa/AgentFramework/cpp/src/include/OpsAgt/DBsupports.h:170
   170     class simpleSelectConstruct{
   /include/OpsAgt/DBsupports.h:170
   170     class simpleSelectConstruct{
  (gdb) p *this
   $2 = {distinct = false, colsToBeSelected = {cols = {<std::_Vector_base<dbCol,   std::allocator<dbCol> >> = {_M_impl = {<std::allocator<dbCol>> =  {<__gnu_cxx::new_allocator<dbCol>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}}, tableName = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x0}}, where = {whereExprs = {<std::_Vector_base<whereExpr, std::allocator<whereExpr> >> = {_M_impl = {<std::allocator<whereExpr>> = {<__gnu_cxx::new_allocator<whereExpr>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, ops = {<std::_Vector_base<adjoinOperator, std::allocator<adjoinOperator> >> = {_M_impl = {<std::allocator<adjoinOperator>> = {<__gnu_cxx::new_allocator<adjoinOperator>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x3dd34bd704, _M_end_of_storage = 0x7ffff7ca52b0}}, <No data fields>}, namespaceCounts = {<std::_Vector_base<unsigned int, std::allocator<unsigned int> >> = {_M_impl = {<std::allocator<unsigned int>> = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No data fields>}, _M_start = 0x7fffdbffe910, _M_finish = 0x6, _M_end_of_storage = 0x4e}}, <No data fields>}, useAsON = false}, groupBy = {cols = {<std::_Vector_base<dbCol, std::allocator<dbCol> >> = {_M_impl = {<std::allocator<dbCol>> = {<__gnu_cxx::new_allocator<dbCol>> = {<No data fields>}, <No data fields>}, _M_start = 0x7fffdbffe910, _M_finish = 0x0, _M_end_of_storage = 0x7ffff6f54d1f}}, <No data fields>}}, orders = {orders = {<std::_Vector_base<orderingTerm, std::allocator<orderingTerm> >> = {_M_impl = {<std::allocator<orderingTerm>> = {<__gnu_cxx::new_allocator<orderingTerm>> = {<No data fields>}, <No data fields>}, _M_start = 0x7ffff7ca52b0, _M_finish = 0x7ffff6f5584d, _M_end_of_storage = 0x5509f0}}, <No data fields>}}, limit = -603988688}
  (gdb) stepi

如果您在构造函数中看到上述限制已损坏,那么_M_start、_M_finish和_M_end_of_storage也是如此。simpleSelectConstruct类如下所示

代码语言:javascript
复制
class simpleSelectConstruct{

 public:
   DBSupportsInterface simpleSelectConstruct()
   {
      distinct=false;
      limit=-1;
   }
   bool distinct;
   dbCols colsToBeSelected;
   string tableName;
   whereConstruct where;
   dbCols groupBy;
   orderBy orders;
   int limit;
};

我已经在https://gcc.gnu.org/ml/gcc-help/2014-08/msg00104.html上发布了完整的信息

EN

回答 1

Stack Overflow用户

发布于 2014-08-15 02:26:52

代码语言:javascript
复制
(gdb) stepi
0x00007ffff0df9b5e      2873            int rc =
_db->fetch_custom_sql_query(rwc.GetQueryName(),selectConstruct,HandleCustomSqlQueryResponse, (void*)&holder);
(gdb) stepi
0x00007ffff0da8000 in simpleSelectConstruct::simpleSelectConstruct ()
from /opt/OV/lbin/OpsAgt/libDMLSegment.so
(gdb) stepi
simpleSelectConstruct::simpleSelectConstruct (this=0x7fffdbffdbb0) 
[SNIP]
(gdb) p *this
[SNIP OUTPUT BEFORE CONSTRUCTOR RUNS]
(gdb) stepi
0x00007ffff0e11892      170     class simpleSelectConstruct{
(gdb) stepi
0x00007ffff0e11894      170     class simpleSelectConstruct{
(gdb) stepi
0x00007ffff0e11896      170     class simpleSelectConstruct{
(gdb) stepi
0x00007ffff0e11898      170     class simpleSelectConstruct{
(gdb) p *this
[SNIP OUTPUT DURING CONSTRUCTOR]
(gdb)
[END OF DEBUGGING SESSION]

我没有看到腐败的证据。我看到您打印出一个未损坏的变量selectConstruct,进入simpleSelectConstruct构造函数,打印即将构造的simpleSelectConstruct,执行四个步骤,然后打印只构造了一半的simpleSelectConstruct。(这两者都不是selectConstruct变量)。你有没有试着等到构造函数完成之后?

当构造函数开始时:

代码语言:javascript
复制
distinct = false
colsToBeSelected = 
    cols = ..._M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0 ...
tableName = ..._M_p = 0x0 ...
where = 
    whereExprs = ..._M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0...
    ops = ..._M_start = 0x0, _M_finish = 0x3dd34bd704, _M_end_of_storage = 0x7ffff7ca52b0...
    namespaceCounts = ..._M_start = 0x7fffdbffe910, _M_finish = 0x6, _M_end_of_storage = 0x4e...
    useAsON = false
groupBy = 
    cols = ..._M_start = 0x7fffdbffe910, _M_finish = 0x0, _M_end_of_storage = 0x7ffff6f54d1f...
orders = ..._M_start = 0x7ffff7ca52b0, _M_finish = 0x7ffff6f5584d, _M_end_of_storage = 0x5509f0...
limit = -603988688

在构造函数中执行了四个步骤后:

代码语言:javascript
复制
distinct = false
colsToBeSelected = 
    cols = ..._M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0 ...
tableName = ..._M_p = 0x0...
where = 
    whereExprs = ..._M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0...
    ops = ..._M_start = 0x0, _M_finish = 0x3dd34bd704, _M_end_of_storage = 0x7ffff7ca52b0...
    namespaceCounts = ..._M_start = 0x7fffdbffe910, _M_finish = 0x6, _M_end_of_storage = 0x4e...
    useAsON = false
groupBy = 
    cols = ..._M_start = 0x7fffdbffe910, _M_finish = 0x0, _M_end_of_storage = 0x7ffff6f54d1f...
orders = ..._M_start = 0x7ffff7ca52b0, _M_finish = 0x7ffff6f5584d, _M_end_of_storage = 0x5509f0...
limit = -603988688

构造函数显然还没有完成执行。现在似乎还处于构建过程的早期阶段。我假设这四个操作都是false,然后是cols,所以下一步就是构造tableName

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25314156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档