From a2c00c6b42c08def536d0867a5cc63f3b065b468 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Jun 2005 16:19:20 +0200 Subject: [PATCH 1/5] ndb - valgrind fixes ndb/src/ndbapi/NdbDictionaryImpl.cpp: valgrind fixes ndb/test/ndbapi/testBlobs.cpp: valgrind fixes --- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 7 ++++++- ndb/test/ndbapi/testBlobs.cpp | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 4523ae2c261..645aa333ea7 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1004,6 +1004,11 @@ NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) return 0; } + // avoid alignment problem and memory overrun + Uint32 name_buf[(MAX_TAB_NAME_SIZE + 3) / 4]; + strncpy((char*)name_buf, name, sizeof(name_buf)); // strncpy null-pads + name = (char*)name_buf; + req->senderRef = m_reference; req->senderData = 0; req->requestType = @@ -1015,7 +1020,7 @@ NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) tSignal.theLength = GetTabInfoReq::SignalLength; LinearSectionPtr ptr[1]; ptr[0].p = (Uint32*)name; - ptr[0].sz = strLen; + ptr[0].sz = (strLen + 3) / 4; return getTable(&tSignal, ptr, 1, fullyQualifiedNames); } diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index a4e7a53a5d1..efbdceac5a6 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -365,7 +365,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) { if (b.m_nullable && urandom(10) == 0) { v.m_len = 0; - delete v.m_val; + delete [] v.m_val; v.m_val = 0; v.m_buf = new char [1]; } else { @@ -375,7 +375,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) v.m_len = urandom(b.m_inline); else v.m_len = urandom(b.m_inline + g_opt.m_parts * b.m_partsize + 1); - delete v.m_val; + delete [] v.m_val; v.m_val = new char [v.m_len + 1]; for (unsigned i = 0; i < v.m_len; i++) v.m_val[i] = 'a' + urandom(25); @@ -1449,6 +1449,7 @@ testperf() if (! testcase('p')) return 0; DBG("=== perf test ==="); + g_bh1 = g_bh2 = 0; g_ndb = new Ndb(g_ncc, "TEST_DB"); CHK(g_ndb->init() == 0); CHK(g_ndb->waitUntilReady() == 0); From b78072633dafab2d5fe08e364d4b8378c188fc16 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Jun 2005 14:58:53 +1000 Subject: [PATCH 2/5] BUG#11132 Connections stuck in CLOSE_WAIT In 4.1 (it is different in 5.0), we do not use the mgm connection after fetching the configuration (and if we did, we would have to have calls to check the connection and reconnect if needed - in case the mgm server had restarted) so we can disconnect after first use. This means we won't have connections stuck in CLOSE_WAIT when the mgm server shuts down. ndb/src/common/mgmcommon/ConfigRetriever.cpp: Disconnect from management server after configuration is fetched. --- ndb/src/common/mgmcommon/ConfigRetriever.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index fd04ad393eb..648f3b4a52c 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -138,7 +138,9 @@ ConfigRetriever::getConfig(NdbMgmHandle m_handle){ setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); return 0; } - + + ndb_mgm_disconnect(m_handle); + return conf; } From 9fb9133f2c1f0524ddbb174c27621ac47fe436b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Jun 2005 22:49:52 +0200 Subject: [PATCH 3/5] cleanup for bug#11167. portability alignment issues. --- sql/sql_select.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2cb650cda2a..41b56ae888c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8112,9 +8112,9 @@ store_record_in_cache(JOIN_CACHE *cache) end > str && end[-1] == ' ' ; end--) ; length=(uint) (end-str); - memcpy(pos+sizeof(uint), str, length); - *((uint *) pos)= length; - pos+= length+sizeof(uint); + memcpy(pos+2, str, length); + int2store(pos, length); + pos+= length+2; } else { @@ -8177,9 +8177,9 @@ read_cached_record(JOIN_TAB *tab) { if (copy->strip) { - memcpy(copy->str, pos+sizeof(uint), length= *((uint *) pos)); + memcpy(copy->str, pos+2, length= uint2korr(pos)); memset(copy->str+length, ' ', copy->length-length); - pos+= sizeof(uint)+length; + pos+= 2+length; } else { From 2074572171104b30ab6c51cd1e756c001c90b72c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jun 2005 10:09:05 +0200 Subject: [PATCH 4/5] fix test results - Bug #11328 mysql-test/r/bdb_cache.result: fix test results mysql-test/t/bdb_cache.test: fix test results --- mysql-test/r/bdb_cache.result | 4 +--- mysql-test/t/bdb_cache.test | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/bdb_cache.result b/mysql-test/r/bdb_cache.result index 218fd489c6a..6506ce0412a 100644 --- a/mysql-test/r/bdb_cache.result +++ b/mysql-test/r/bdb_cache.result @@ -12,10 +12,9 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 drop table t1; -commit; set autocommit=1; -begin; create table t1 (a int not null) engine=bdb; +begin; insert into t1 values (1),(2),(3); select * from t1; a @@ -26,7 +25,6 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 drop table t1; -commit; create table t1 (a int not null) engine=bdb; create table t2 (a int not null) engine=bdb; create table t3 (a int not null) engine=bdb; diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test index 0082c83faff..401456711ac 100644 --- a/mysql-test/t/bdb_cache.test +++ b/mysql-test/t/bdb_cache.test @@ -14,15 +14,13 @@ insert into t1 values (1),(2),(3); select * from t1; show status like "Qcache_queries_in_cache"; drop table t1; -commit; set autocommit=1; -begin; create table t1 (a int not null) engine=bdb; +begin; insert into t1 values (1),(2),(3); select * from t1; show status like "Qcache_queries_in_cache"; drop table t1; -commit; create table t1 (a int not null) engine=bdb; create table t2 (a int not null) engine=bdb; create table t3 (a int not null) engine=bdb; From 17b55ca39b47c578329a61a07d2ffddeb3e91f22 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jun 2005 13:39:54 +0200 Subject: [PATCH 5/5] for consictency, changed to use memcpy_fixed. --- sql/sql_select.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 41b56ae888c..352227acc68 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8112,9 +8112,9 @@ store_record_in_cache(JOIN_CACHE *cache) end > str && end[-1] == ' ' ; end--) ; length=(uint) (end-str); - memcpy(pos+2, str, length); - int2store(pos, length); - pos+= length+2; + memcpy(pos+sizeof(length), str, length); + memcpy_fixed(pos, &length, sizeof(length)); + pos+= length+sizeof(length); } else { @@ -8177,9 +8177,10 @@ read_cached_record(JOIN_TAB *tab) { if (copy->strip) { - memcpy(copy->str, pos+2, length= uint2korr(pos)); + memcpy_fixed(&length, pos, sizeof(length)); + memcpy(copy->str, pos+sizeof(length), length); memset(copy->str+length, ' ', copy->length-length); - pos+= 2+length; + pos+= sizeof(length)+length; } else {