Skip to content

Commit 71e50b4

Browse files
committed
Bug#37300558 segmentation fault in Ndb_cluster_connection Dtor
Problem: Ndb_cluster_connection destructor calls g_eventLogger::stopAsync() in order to release the buffers used by the async log mechanism as well as to stop the threads responsible for the async logging. Problem is that, if g_eventLogger object is deleted before the destructor of the Ndb_cluster_connection is called, program crash because it is trying to use a method on a null object. This can happen in two different ways: 1- Api programs deletes the logger object before deleting the Ndb_cluster_connection 2- ndb_end() is called before Ndb_cluster_connection is deleted. Solution: In cluster_connection Destructor do not call stopAsync() when g_eventLogger object is NULL. A warning is also added to inform API users that g_eventLogger is *wrongly* deleted before cluster_connection Dtor is called. Change-Id: I57ff648949a60b45841e8b568030259f1540180b
1 parent 8a21a5a commit 71e50b4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

storage/ndb/src/ndbapi/ndb_cluster_connection.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,14 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() {
613613
NdbMutex_Destroy(ndb_print_state_mutex);
614614
ndb_print_state_mutex = nullptr;
615615
#endif
616-
g_eventLogger->stopAsync();
616+
if (g_eventLogger != nullptr) {
617+
g_eventLogger->stopAsync();
618+
} else {
619+
[[maybe_unused]] int ret =
620+
fprintf(stderr,
621+
"WARNING: g_eventLogger object is "
622+
"deleted. ndb_end() called too soon?\n");
623+
}
617624
}
618625
NdbMutex_Unlock(g_ndb_connection_mutex);
619626

0 commit comments

Comments
 (0)