Skip to content

Commit d09dfd6

Browse files
saurabh500Copilot
andcommitted
Remove unsafe LOG() call in destructor/shutdown disconnect path
LOG() internally acquires the GIL via py::gil_scoped_acquire, which is unsafe during interpreter shutdown or stack unwinding — it can deadlock or trigger std::terminate(). Replace with a comment explaining why logging is intentionally skipped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b753411 commit d09dfd6

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

mssql_python/pybind/connection/connection.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ void Connection::disconnect() {
164164
if (hasGil) {
165165
checkError(ret);
166166
} else if (!SQL_SUCCEEDED(ret)) {
167-
LOG("SQLDisconnect failed in destructor/shutdown path; ignoring error");
167+
// Intentionally no LOG() here: LOG() acquires the GIL internally
168+
// via py::gil_scoped_acquire, which is unsafe during interpreter
169+
// shutdown or stack unwinding (can deadlock or call std::terminate).
168170
}
169171
// triggers SQLFreeHandle via destructor, if last owner
170172
_dbcHandle.reset();

0 commit comments

Comments
 (0)