From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20886 invoked by alias); 14 Aug 2014 16:18:17 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 20866 invoked by uid 89); 14 Aug 2014 16:18:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f176.google.com Received: from mail-ig0-f176.google.com (HELO mail-ig0-f176.google.com) (209.85.213.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 14 Aug 2014 16:18:09 +0000 Received: by mail-ig0-f176.google.com with SMTP id hn18so14057392igb.9 for ; Thu, 14 Aug 2014 09:18:07 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.118.4 with SMTP id ki4mr60386550igb.16.1408033087224; Thu, 14 Aug 2014 09:18:07 -0700 (PDT) Received: by 10.107.12.73 with HTTP; Thu, 14 Aug 2014 09:18:07 -0700 (PDT) Date: Thu, 14 Aug 2014 16:18:00 -0000 Message-ID: Subject: Corruption in C++ constructor From: navin p To: gcc-help@gcc.gnu.org, gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00039.txt.bz2 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 = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }}, tableName = {static npos = 18446744073709551615, _M_dataplus = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x3dd36f32d8 ""}}, where = {whereExprs = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }, ops = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }, namespaceCounts = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }, useAsON = false}, groupBy = {cols = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }}, orders = {orders = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }}, 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 = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }}, tableName = {static npos = 18446744073709551615, _M_dataplus = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x0}}, where = {whereExprs = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }, ops = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x3dd34bd704, _M_end_of_storage = 0x7ffff7ca52b0}}, }, namespaceCounts = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7fffdbffe910, _M_finish = 0x6, _M_end_of_storage = 0x4e}}, }, useAsON = false}, groupBy = {cols = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7fffdbffe910, _M_finish = 0x0, _M_end_of_storage = 0x7ffff6f54d1f}}, }}, orders = {orders = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7ffff7ca52b0, _M_finish = 0x7ffff6f5584d, _M_end_of_storage = 0x5509f0}}, }}, 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 = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }}, tableName = {static npos = 18446744073709551615, _M_dataplus = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x0}}, where = {whereExprs = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, }, ops = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x0, _M_finish = 0x3dd34bd704, _M_end_of_storage = 0x7ffff7ca52b0}}, }, namespaceCounts = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7fffdbffe910, _M_finish = 0x6, _M_end_of_storage = 0x4e}}, }, useAsON = false}, groupBy = {cols = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7fffdbffe910, _M_finish = 0x0, _M_end_of_storage = 0x7ffff6f54d1f}}, }}, orders = {orders = { >> = {_M_impl = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_start = 0x7ffff7ca52b0, _M_finish = 0x7ffff6f5584d, _M_end_of_storage = 0x5509f0}}, }}, limit = -603988688} (gdb) #ifndef my_db_supports_h #define my_db_supports_h #include #include 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 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 vals; public: DBSupportsInterface void addValue(dbColValue _val); DBSupportsInterface dbColValue & getValueAt(int i); DBSupportsInterface int getNumValues(); }; class dbCols{ protected: vector 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 is_in_list; }; class orderingTerm{ public: dbCol col; order_e order; }; class orderBy{ public: vector orders; DBSupportsInterface void addOrder(orderingTerm _o); OvXplStr::String_t getOrderByConstruct(); }; class whereConstruct{ protected: vector whereExprs; vector ops; vector 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 */