Re: Corruption in C++ constructor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This isn't really a question about the compiler.  There are other
places to get help debugging your program.

That said, it is very difficult to help in debugging without seeing
the code that causes the problem - a header isn't in this case a
complete program.  You should work to make the smallest possible test
case that you can so that people can help you.


On Thu, Aug 14, 2014 at 11:18 AM, navin p <navinp1281@xxxxxxxxx> wrote:
> Hi,
>  Sorry for the long post but i'm stuck . Can someone help me ?
>
>  I'm debugging a multithreaded program. I've inlined the headerfile below.
> Now when i print selectConstruct i get all the vectors with M_start as 0 .
>
> Now when i call the constructor ie when the selectConstruct is passed
> by value to the function fetch_custom_sql_query to create a temporary
> object it changes the M_start and M_finish as below in the second
> snapshot print *this.
>
> As you can see limit is -1 but it is corrupted after the call to
> constructor ie p *this.
>
> Is this a corruption , how do i debug this ?
>
> 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
> 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
> $3 = {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)
>
>
> #ifndef my_db_supports_h
> #define my_db_supports_h
>
> #include <string>
> #include <vector>
> namespace std {}
> using namespace std;
>
> #include "OvXplStr/NlString.h"
>
> #if defined(WINDOWS)
>   #if defined(EXPORT_LIB)
>     #define DBSupportsInterface __declspec(dllexport)
>   #else
>     #define DBSupportsInterface //__declspec(dllimport)
>   #endif
> #else
>   #define DBSupportsInterface
> #endif
>
> typedef enum
> {
>  data_type_integer = 0,
>  data_type_text,
>  data_type_real,
>  data_type_numeric,
>  data_type_time,
>  data_type_autokey,
>  data_type_none
> } db_ColumnDataType;
>
> typedef enum
> {
>  ascending = 0,
>  descending
> } order_e;
>
> typedef enum
> {
>  is_equal_to = 0,
>  is_not_equal_to,
>  is_greater_than,
>  is_greater_than_or_equal,
>  is_less_than,
>  is_less_than_or_equal,
>  is_in
> } whereOperator;
>
> typedef enum
> {
>  _AND_ = 100,
>  _OR_
> } adjoinOperator;
>
> class dbColumnDef {
>
>  protected:
>    OvXplStr::String_t name;
>    db_ColumnDataType type;
>    bool isPartOfPrimaryKey;
>    int isPartOfUniqueness;
>    bool isForeignKey;
>    OvXplStr::String_t foreignTableName;
>    OvXplStr::String_t foreignColumnName;
>
>  public:
>
>    DBSupportsInterface dbColumnDef();
>    DBSupportsInterface dbColumnDef(const dbColumnDef & _dbCol);
>    DBSupportsInterface void setName(OvXplStr::String_t _name);
>    DBSupportsInterface void setType(db_ColumnDataType _type);
>    DBSupportsInterface void setIsPartOfPrimaryKey(bool _v);
>    DBSupportsInterface void setIsPartOfUniqueness(int _v);
>    DBSupportsInterface void setForeignKeyReference(OvXplStr::String_t
> _fTableName, OvXplStr::String_t _fColName);
>
>    DBSupportsInterface OvXplStr::String_t getName();
>    DBSupportsInterface db_ColumnDataType getType();
>    DBSupportsInterface bool getIsPartOfPrimaryKey();
>    DBSupportsInterface int getIsPartOfUniqueness();
>    DBSupportsInterface bool getIsForeignKey();
>    DBSupportsInterface OvXplStr::String_t getForeignTableName();
>    DBSupportsInterface OvXplStr::String_t getForeignColumnName();
>
> };
>
> class dbColumnDefs{
>    private:
>       vector<dbColumnDef> cols;
>
>    public:
>       DBSupportsInterface void addColumnDef(dbColumnDef _col);
>       DBSupportsInterface dbColumnDef& getColumnDefAt(int i);
>       DBSupportsInterface int getNumColumnDefs();
> };
>
> class dbCol{
>  public:
>    OvXplStr::String_t colName;
>    db_ColumnDataType type;
>    DBSupportsInterface dbCol();
> };
>
> class dbColValue: public dbCol{
>  public:
>    OvXplStr::String_t value;
>    DBSupportsInterface dbColValue();
> };
>
> class dbColValues{
>
>  protected:
>    vector<dbColValue> vals;
>
>  public:
>    DBSupportsInterface void addValue(dbColValue _val);
>    DBSupportsInterface dbColValue & getValueAt(int i);
>    DBSupportsInterface int getNumValues();
> };
>
> class dbCols{
>
>  protected:
>    vector<dbCol> cols;
>
>  public:
>    DBSupportsInterface void addColumn(dbCol _val);
>    DBSupportsInterface dbCol & getColumnAt(int i);
>    DBSupportsInterface int getNumColumns();
> };
>
> class whereExpr{
>  public:
>    dbCol col;
>    whereOperator op;
>    OvXplStr::String_t value;
>    vector<OvXplStr::String_t> is_in_list;
> };
>
> class orderingTerm{
>  public:
>    dbCol col;
>    order_e order;
> };
>
> class orderBy{
>  public:
>    vector<orderingTerm> orders;
>    DBSupportsInterface void addOrder(orderingTerm _o);
>    OvXplStr::String_t getOrderByConstruct();
> };
>
> class whereConstruct{
>  protected:
>    vector<whereExpr> whereExprs;
>    vector<adjoinOperator> ops;
>    vector<unsigned int> namespaceCounts;
>    bool useAsON;
>  public:
>    DBSupportsInterface whereConstruct(bool b = false) {
>       useAsON=b;
>    }
>    DBSupportsInterface void addWhereExpr(whereExpr _w);
>    DBSupportsInterface void addAdjoiningOp(adjoinOperator _op);
>    DBSupportsInterface void addNameSpaceBoundary(unsigned int);
>    DBSupportsInterface OvXplStr::String_t getWhereConstruct();
>    DBSupportsInterface size_t getNumWhereExprs();
>    DBSupportsInterface bool UseAsON();
> };
>
> class simpleSelectConstruct{
>
>  public:
>    DBSupportsInterface simpleSelectConstruct()
>    {
>       distinct=false;
>       limit=-1;
>    }
>    bool distinct;
>    dbCols colsToBeSelected;
>    string tableName;
>    whereConstruct where;
>    dbCols groupBy;
>    orderBy orders;
>    int limit;
> };
>
> class dbUtils
> {
> public:
>     static OvXplStr::String_t makeEscapedString(OvXplStr::String_t
> unEscapedStr);
> };
>
> #endif /* my_db_supports_h */



-- 
Andrew Bell
andrew.bell.ia@xxxxxxxxx




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux