diff --git a/fastbit/fastbit-ibis1.3.5/src/column.cpp b/fastbit/fastbit-ibis1.3.5/src/column.cpp
index 44ce5cb..6d7b043 100644
--- a/fastbit/fastbit-ibis1.3.5/src/column.cpp
+++ b/fastbit/fastbit-ibis1.3.5/src/column.cpp
@@ -37,6 +37,26 @@ static const char* _ibis_TYPESTRING_local[] = {
 };
 FASTBIT_CXX_DLLSPEC const char** ibis::TYPESTRING = _ibis_TYPESTRING_local;
 
+void mutex_init(pthread_mutex_t& mutex) {
+    pthread_mutexattr_t mutex_attr;
+    if (0 !=  pthread_mutexattr_init(&mutex_attr)) {
+	throw "column::ctor unable to initialize the mutex attr";
+    }
+    // it is necessary to use recursive mutex because the
+    // following call graph acquires the mutex twice and
+    // would otherwise cause deadlock:
+    // ibis::category::prepareMembers ->
+    // ibis::category::fillRows ->
+    // ibis::direkte::direkte ->
+    // ibis::column::getNullMask
+    if (0 != pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE)) {
+	throw "column::ctor unable to set mutex attr type";
+    }
+    if (0 != pthread_mutex_init(&mutex, &mutex_attr)) {
+	throw "column::ctor unable to initialize the mutex";
+    }
+}
+
 /// Construct a new column object based on type and name.
 ibis::column::column(const ibis::part* tbl, ibis::TYPE_T t,
 		     const char* name, const char* desc,
@@ -46,10 +66,7 @@ ibis::column::column(const ibis::part* tbl, ibis::TYPE_T t,
     if (0 != pthread_rwlock_init(&rwlock, 0)) {
 	throw "column::ctor unable to initialize the rwlock";
     }
-    if (0 != pthread_mutex_init
-	(&mutex, static_cast<const pthread_mutexattr_t*>(0))) {
-	throw "column::ctor unable to initialize the mutex";
-    }
+    mutex_init(mutex);
     if (m_desc.empty()) m_desc = name;
     if (ibis::gVerbose > 5 && !m_name.empty()) {
 	ibis::util::logger lg;
@@ -78,10 +95,7 @@ ibis::column::column(const part* tbl, FILE* file)
     if (0 != pthread_rwlock_init(&rwlock, 0)) {
 	throw "column::ctor unable to initialize the rwlock";
     }
-    if (0 != pthread_mutex_init
-	(&mutex, static_cast<const pthread_mutexattr_t *>(0))) {
-	throw "column::ctor unable to initialize the mutex";
-    }
+    mutex_init(mutex);
 
     bool badType = false;
     // read the column entry of the metadata file
@@ -310,9 +324,7 @@ ibis::column::column(const ibis::column& rhs) :
     if (pthread_rwlock_init(&rwlock, 0)) {
 	throw "column::ctor unable to initialize the rwlock";
     }
-    if (pthread_mutex_init(&mutex, 0)) {
-	throw "column::ctor unable to initialize the mutex";
-    }
+    mutex_init(mutex);
     if (ibis::gVerbose > 5 && !m_name.empty()) {
 	ibis::util::logger lg;
 	lg() << "made a new copy of column ";
