MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:July 14 2010 1:11pm
Subject:bzr push into mysql-5.1-bugteam branch (davi:3481 to 3482) Bug#48327
View as plain text  
 3482 Davi Arnaut	2010-07-14
      Bug#48327: Some crashes specific to FreeBSD ("embedded")
      
      Backport fixes from ndb: Rework the constructors of some static
      object's to not call dbug functions since the constructors will
      be called before main, and consequently, before the dbug library
      is initialized.

    modified:
      storage/ndb/src/common/portlib/NdbMutex.c
      storage/ndb/src/ndbapi/DictCache.cpp
 3481 Georgi Kodinov	2010-07-14
      Bug #51876: crash/memory underrun when loading data with ucs2
      and reverse() function
            
      3 problems fixed : 
      1. The reported problem : caused by incorrect parsing of 
      the file as ucs data resulting in wrong length of the parsed
      string. Fixed by truncating the invalid trailing bytes 
      (non-complete multibyte characters) when reading from the file
      2. LOAD DATA when reading from a proper UCS2 file wasn't 
      recognizing the new line characters. Fixed by first looking 
      if a byte is a new line (or any other special) character before
      reading it as a part of a multibyte character.
      3. When using user variables to hold the column data in LOAD
      DATA the character set of the user variable was set incorrectly
      to the database charset. Fixed by setting it to the charset
      specified by LOAD DATA (if any). 

    modified:
      mysql-test/r/loaddata.result
      mysql-test/t/loaddata.test
      sql/item_func.cc
      sql/sql_load.cc
=== modified file 'storage/ndb/src/common/portlib/NdbMutex.c'
--- a/storage/ndb/src/common/portlib/NdbMutex.c	2006-12-23 19:20:40 +0000
+++ b/storage/ndb/src/common/portlib/NdbMutex.c	2010-07-14 13:10:12 +0000
@@ -24,36 +24,31 @@ NdbMutex* NdbMutex_Create(void)
 {
   NdbMutex* pNdbMutex;
   int result;
-  DBUG_ENTER("NdbMutex_Create");
-  
+
   pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex));
-  DBUG_PRINT("info",("NdbMem_Allocate 0x%lx", (long) pNdbMutex));
-  
+
   if (pNdbMutex == NULL)
-    DBUG_RETURN(NULL);
-  
+    return NULL;
+
   result = pthread_mutex_init(pNdbMutex, NULL);
   assert(result == 0);
-			     
-  DBUG_RETURN(pNdbMutex);		     
+
+  return pNdbMutex;
 }
 
 
 int NdbMutex_Destroy(NdbMutex* p_mutex)
 {
   int result;
-  DBUG_ENTER("NdbMutex_Destroy");
 
   if (p_mutex == NULL)
-    DBUG_RETURN(-1);
+    return -1;
 
   result = pthread_mutex_destroy(p_mutex);
 
-  DBUG_PRINT("info",("NdbMem_Free 0x%lx", (long) p_mutex));
   NdbMem_Free(p_mutex);
-			     
-  DBUG_RETURN(result);
 
+  return result;
 }
 
 

=== modified file 'storage/ndb/src/ndbapi/DictCache.cpp'
--- a/storage/ndb/src/ndbapi/DictCache.cpp	2009-05-15 12:57:51 +0000
+++ b/storage/ndb/src/ndbapi/DictCache.cpp	2010-07-14 13:10:12 +0000
@@ -20,8 +20,10 @@
 #include <NdbCondition.h>
 #include <NdbSleep.h>
 
-static NdbTableImpl f_invalid_table;
-static NdbTableImpl f_altered_table;
+static NdbTableImpl * f_invalid_table = 0;
+static NdbTableImpl * f_altered_table = 0;
+
+static int ndb_dict_cache_count = 0;
 
 Ndb_local_table_info *
 Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz)
@@ -93,11 +95,29 @@ GlobalDictCache::GlobalDictCache(){
   DBUG_ENTER("GlobalDictCache::GlobalDictCache");
   m_tableHash.createHashTable();
   m_waitForTableCondition = NdbCondition_Create();
+  if (f_invalid_table == NULL)
+    f_invalid_table = new NdbTableImpl();
+  if (f_altered_table == NULL)
+    f_altered_table = new NdbTableImpl();
+  ndb_dict_cache_count++;
   DBUG_VOID_RETURN;
 }
 
 GlobalDictCache::~GlobalDictCache(){
   DBUG_ENTER("GlobalDictCache::~GlobalDictCache");
+  if (--ndb_dict_cache_count == 0)
+  {
+    if (f_invalid_table)
+    {
+      delete f_invalid_table;
+      f_invalid_table = 0;
+    }
+    if (f_altered_table)
+    {
+      delete f_altered_table;
+      f_altered_table = 0;
+    }
+  }
   NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
   while(curr != 0){
     Vector<TableVersion> * vers = curr->theData;
@@ -254,7 +274,7 @@ GlobalDictCache::put(const char * name,
   TableVersion & ver = vers->back();
   if(ver.m_status != RETREIVING || 
      !(ver.m_impl == 0 || 
-       ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || 
+       ver.m_impl == f_invalid_table || ver.m_impl == f_altered_table) || 
      ver.m_version != 0 || 
      ver.m_refCount == 0){
     abort();
@@ -271,7 +291,7 @@ GlobalDictCache::put(const char * name,
     ver.m_version = tab->m_version;
     ver.m_status = OK;
   } 
-  else if (ver.m_impl == &f_invalid_table) 
+  else if (ver.m_impl == f_invalid_table) 
   {
     DBUG_PRINT("info", ("Table DROPPED invalid"));
     ver.m_impl = tab;
@@ -279,7 +299,7 @@ GlobalDictCache::put(const char * name,
     ver.m_status = DROPPED;
     ver.m_impl->m_status = NdbDictionary::Object::Invalid;    
   }
-  else if(ver.m_impl == &f_altered_table)
+  else if(ver.m_impl == f_altered_table)
   {
     DBUG_PRINT("info", ("Table DROPPED altered"));
     ver.m_impl = tab;
@@ -440,7 +460,7 @@ GlobalDictCache::alter_table_rep(const c
 
     if(i == sz - 1 && ver.m_status == RETREIVING)
     {
-      ver.m_impl = altered ? &f_altered_table : &f_invalid_table;
+      ver.m_impl = altered ? f_altered_table : f_invalid_table;
       DBUG_VOID_RETURN;
     } 
   }


Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20100714131012-btyvcruo9ot6ddzc.bundle
Thread
bzr push into mysql-5.1-bugteam branch (davi:3481 to 3482) Bug#48327Davi Arnaut14 Jul