Bug#1141620: trixie-pu: package unixodbc/2.3.12-2+deb13u1

Hugh McMaster <[email protected]>
Newsgroups gmane.linux.debian.devel.release
Message-ID <178342731322.107744.14464267605972306898.reportbug__9770.0478670717$1783427494$gmane$org@debian>
Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: [email protected]
Control: affects -1 + src:unixodbc
User: [email protected]
Usertags: pu

[ Reason ]
odbcinst2 is leaking memory. After a dlclose(), libodbcinst2 still has a
dynamically allocated ini cache and memory allocation for the odbcinst logger.

[ Impact ]
The leak occurs on all systems with ini-caching enabled at build time, which is
all Debian systems.

Broadly, the bug is impacting MariaDB ODBC connector. MariaDB developers
reported the bug to the upstream unixODBC.

[ Tests ]
See, for example, https://jira.mariadb.org/browse/MDEV-38838.

[ Risks ]
Memory leaks remain and impact systems using MariaDB and other databases with
unixODBC.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
The upstream patch declares the relevant destructor at compile time, adds
inst_logClose() to close and clear ODBCINSTLog, and calls inst_logClose() and
__clear_ini_cache() on shared library closure.

This version also introduces a new symbol, inst_logClose, which is fine.

[ Other info ]
Upstream MariaDB is requesting an upload to Debian stable, which I support (see
#1141600).
unixodbc-2.3.12-2+deb13u1.debdiff (text/plain, 3.6 KB)
diff -Nru unixodbc-2.3.12/debian/changelog unixodbc-2.3.12/debian/changelog
--- unixodbc-2.3.12/debian/changelog	2024-12-17 22:34:56.000000000 +1100
+++ unixodbc-2.3.12/debian/changelog	2026-07-07 22:00:05.000000000 +1000
@@ -1,3 +1,11 @@
+unixodbc (2.3.12-2+deb13u1) trixie; urgency=medium
+
+  * debian/libodbcinst2.symbols: Add inst_logClose@Base.
+  * debian/patches: Clear cached allocations on dlclose() in libodbcinst2
+    (Closes: #1136221).
+
+ -- Hugh McMaster <[email protected]>  Tue, 07 Jul 2026 22:00:05 +1000
+
 unixodbc (2.3.12-2) unstable; urgency=medium
 
   * debian/control:
diff -Nru unixodbc-2.3.12/debian/libodbcinst2.symbols unixodbc-2.3.12/debian/libodbcinst2.symbols
--- unixodbc-2.3.12/debian/libodbcinst2.symbols	2024-12-16 18:32:11.000000000 +1100
+++ unixodbc-2.3.12/debian/libodbcinst2.symbols	2026-07-07 21:59:05.000000000 +1000
@@ -81,6 +81,7 @@
  iniPropertyNext@Base 2.3.1
  iniToUpper@Base 2.3.1
  iniValue@Base 2.3.1
+ inst_logClose@Base 2.3.12
  inst_logPushMsg@Base 2.3.1
  odbcinst_system_file_name@Base 2.3.1
  odbcinst_system_file_path@Base 2.3.1
diff -Nru unixodbc-2.3.12/debian/patches/1136221.patch unixodbc-2.3.12/debian/patches/1136221.patch
--- unixodbc-2.3.12/debian/patches/1136221.patch	1970-01-01 10:00:00.000000000 +1000
+++ unixodbc-2.3.12/debian/patches/1136221.patch	2026-07-07 21:59:05.000000000 +1000
@@ -0,0 +1,76 @@
+Description: Clear cached allocations on dlclose() in libodbcinst2
+ * Declare destructors at configure time.
+ * New libodbcinst2 symbol inst_logClose.
+ * Add inst_logClose() to close and clear ODBCINSTLog.
+ * Call inst_logClose() and __clear_ini_cache() on shared library closure.
+ 
+ Patch derived from upstream commits:
+   * e545d3dd29c7290a70992c1b2b1de4f6219e1a6f
+   * a2cecd22d0509bf550053e8b7d654936af4c7540
+
+ See also: https://github.com/lurcher/unixODBC/pull/234
+Author: Daniel Black, Nick Gorham
+Bug: https://github.com/lurcher/unixODBC/issues/130
+Bug: https://github.com/lurcher/unixODBC/issues/207
+Bug-Debian: https://bugs.debian.org/1136221
+Last-Updated: 2026-05-14
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -590,6 +590,20 @@
+    done
+ ])
+ 
++dnl see if we can declare a destructor
++AC_MSG_CHECKING([if __attribute__((destructor)) works])
++AC_COMPILE_IFELSE(
++    [AC_LANG_PROGRAM([__attribute__((destructor))], [int x = 0;])],
++    [
++        AC_MSG_RESULT( yes )
++        AC_DEFINE([PORTABLE_DESTRUCTOR],[__attribute__((destructor))],[Declare function as a destructor])
++    ],
++    [
++        AC_MSG_RESULT( no )
++        AC_DEFINE([PORTABLE_DESTRUCTOR],[],[Declare function as a destructor])
++    ]
++)
++
+ dnl AC_SUBST(all_includes)
+ dnl AC_SUBST(all_libraries)
+ 
+--- a/odbcinst/SQLGetPrivateProfileString.c
++++ b/odbcinst/SQLGetPrivateProfileString.c
+@@ -327,6 +327,7 @@
+ 	mutex_exit( &mutex_ini );
+ }
+ 
++PORTABLE_DESTRUCTOR
+ void __clear_ini_cache( void ) 
+ {
+ 	mutex_entry( &mutex_ini );
+--- a/odbcinst/_logging.c
++++ b/odbcinst/_logging.c
+@@ -201,3 +201,15 @@
+     return ret;
+ }
+ 
++PORTABLE_DESTRUCTOR
++void inst_logClose( void )
++{
++
++    local_mutex_entry();
++
++    if ( hODBCINSTLog ) {
++        logClose( hODBCINSTLog );
++    }
++
++    local_mutex_exit();
++}
+--- a/odbcinst/odbcinst.exp
++++ b/odbcinst/odbcinst.exp
+@@ -83,4 +83,5 @@
+ iniToUpper
+ iniValue
+ inst_logPushMsg
++inst_logClose
+ __clear_ini_cache
diff -Nru unixodbc-2.3.12/debian/patches/series unixodbc-2.3.12/debian/patches/series
--- unixodbc-2.3.12/debian/patches/series	2024-12-16 22:02:24.000000000 +1100
+++ unixodbc-2.3.12/debian/patches/series	2026-07-07 21:59:05.000000000 +1000
@@ -1 +1,2 @@
 0001-configure-ac-cursor-lib.patch
+1136221.patch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.