On Tue, Apr 29, 2014 at 04:42:13PM -0500, Anthony Minessale wrote: > Package: unixodbc > Version: 2.2.14p2-5
> Unixodbc is patched to use libltdl Unixodbc already uses libltdl upstream. It is patched to use the distro version of libltdl instead of the bundled one, but that doesn't seem to be relevant here. The distro-specific patch is the use of lt_dlsetsearchpath() in particular. > The following stack trace shows a double free coming from lt_dlsetsearchpath() > when multithread usage of odbc is being done with FreeSWITCH > #0 0x00007f3aed113475 in raise () from /lib/x86_64-linux-gnu/libc.so.6 > #1 0x00007f3aed1166f0 in abort () from /lib/x86_64-linux-gnu/libc.so.6 > #2 0x00007f3aed14e52b in ?? () from /lib/x86_64-linux-gnu/libc.so.6 > #3 0x00007f3aed157d76 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 > #4 0x00007f3aed15cb1c in free () from /lib/x86_64-linux-gnu/libc.so.6 > #5 0x00007f3aeceddc65 in lt_dlsetsearchpath () from > /usr/lib/x86_64-linux-gnu/libltdl.so.7 > #6 0x00007f3aeed9c103 in ?? () from /usr/lib/x86_64-linux-gnu/libodbc.so.1 > #7 0x00007f3aeed9edfc in SQLConnect () from > /usr/lib/x86_64-linux-gnu/libodbc.so.1 This backtrace doesn't include any information that shows that the problem is a double-free. I can see from the code how a double-free could occur, but do you have a more definitive trace that confirms this is the problem you're running into? > According to the documentation at > http://www.delorie.com/gnu/docs/libtool/libtool_46.html > Note that libltdl is not threadsafe, i.e. a multithreaded application has > to use a mutex for libltdl. It was reported that GNU/Linux's glibc 2.0's > dlopen with `RTLD_LAZY' (which libltdl uses by default) is not thread-safe, > but this problem is supposed to be fixed in glibc 2.1. On the other hand, > `RTLD_NOW' was reported to introduce problems in multi-threaded > applications on FreeBSD. Working around these problems is left as an > exercise for the reader; contributions are certainly welcome. That seems unrelated to the use of lt_dlsetsearchpath(), which does not invoke dlopen(). > I think the patch needs to be changed to use this lib with a mutex to avoid > memory corruption when concurrent calls to opening sql drivers are > performed in a multi-threaded app or the use of this libltdl should be > discontinued. Does the attached patch fix the problem for you? -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ slanga...@ubuntu.com vor...@debian.org
=== modified file 'DriverManager/SQLConnect.c' --- a/DriverManager/SQLConnect.c 2013-05-30 15:03:20 +0000 +++ b/DriverManager/SQLConnect.c 2014-04-29 22:32:14 +0000 @@ -1090,7 +1090,9 @@ */ lt_dlinit(); + mutex_lib_entry(); lt_dlsetsearchpath(MODULEDIR); + mutex_lib_exit(); /* * open the lib === modified file 'debian/changelog' --- a/debian/changelog 2014-04-06 10:06:33 +0000 +++ b/debian/changelog 2014-04-29 22:32:14 +0000 @@ -1,3 +1,11 @@ +unixodbc (2.3.1-3) UNRELEASED; urgency=low + + * DriverManager/SQLConnect.c: put a mutex around the call to + lt_dlsetsearchpath(), to avoid double-frees in a multithreaded context. + Closes: #746423. + + -- Steve Langasek <vor...@debian.org> Tue, 29 Apr 2014 15:31:35 -0700 + unixodbc (2.3.1-2) unstable; urgency=medium * Use dh-autoreconf instead of a homegrown autotools target; this fixes
signature.asc
Description: Digital signature