Bug #18322 Explicit link to libmtmalloc breaks dlopen() applications like DBD::mysql
Submitted: 18 Mar 2006 7:00 Modified: 5 Dec 2007 19:19
Reporter: Dean Ellis
Status: Closed
Category:Server: Compiling Severity:S2 (Serious)
Version:4.1.18, 5.0.40 OS:Sun Solaris (Solaris)
Assigned to: Kent Boortz Target Version:5.0+
Tags: bfsm_2007_05_31, regression

[18 Mar 2006 7:00] Dean Ellis
Description:
Our Solaris builds are apparently explicitly linked to libmtmalloc.  This library cannot
be dlopen()ed, so we are breaking programs such as DBD::mysql that attempt to dlopen() our
client library.

ie:
$ mysql_config --libs
-m64 -O2 -g -mtune=k8 -static-libgcc -L/opt/mysql/mysql/lib -lmysqlclient -lz -lposix4
-lgen -lsocket -lnsl -lm -lmtmalloc

How to repeat:
Build DBD::mysql against a 4.1.18 client library; during make test you will see messages
similar to:

Can't load 'DBD-mysql-3.0002/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
ld.so.1: perl: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed
at /opt/csw/lib/perl/5.8.8/DynaLoader.pm line 230.

Suggested fix:
Do not explicitly link to libmtmalloc.  The performance gain for this library should be
configurable at runtime (ie: LD_PRELOAD=/usr/lib/libmtmalloc.so) for the server, where it
will have benefit, without breaking the client.
[27 Mar 2006 19:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4204
[31 Mar 2006 13:36] Kent Boortz
The library "-lmtmalloc" was removed from the output of
"mysql_config" on Solaris. Even if the MySQL server is built
with this optional library, there is no need and we shoud not,
force users of our libraries to use it. It caused problems for
building "DBD::mysql" and maybe other applications.
[6 Apr 2006 15:42] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented fix in 4.1.19 changelog. Closed.
[22 May 2007 8:22] Trent Lloyd
This appears to affect 5.0.40 as well
(mysql-enterprise-gpl-5.0.40-solaris10-sparc) now that shared libraries are
being distributed in this version, that were not in previous versions (bug #26767)
[22 May 2007 8:25] Sveta Smirnova
Re-verified, because bug exists in 5.0.40 packages.
[19 Jun 2007 12:43] Joerg Bruehe
Comment of this changeset:

ChangeSet@1.2660, 2007-05-30 22:11:53+02:00, kent@mysql.com +2 -0
  Makefile.am, configure.in:
    Added --with-mysqld-libs configure flag

  configure.in@1.432, 2007-05-30 22:11:44+02:00, kent@mysql.com +6 -0
    Added --with-mysqld-libs configure flag

  sql/Makefile.am@1.119, 2007-05-30 22:11:44+02:00, kent@mysql.com +2 -1
    Added --with-mysqld-libs configure flag

I approve of it.
[9 Jul 2007 18:08] Kent Boortz
Change is in 5.0.44 and 5.1.20
[9 Jul 2007 21:10] Paul DuBois
Noted in 5.0.44, 5.1.20 changelogs.

The -lmtmalloc library was removed from the output of mysql_config on
Solaris, as it caused problems when building DBD::mysql (and possibly
other applications) on that platform that tried to use dlopen() to
access the client library.
[23 Nov 2007 0:04] Sveta Smirnova
Bug still exists in version 5.1.22: libmysqlclient.so linked with libmtmalloc. See also
bug #32012

$ldd /users/ssmirnova/sol10-sparc-c/build/mysql-5.1.22-rcb/lib/mysql/libmysqlclient.so
        librt.so.1 =>    /lib/librt.so.1
        libgen.so.1 =>   /lib/libgen.so.1
        libsocket.so.1 =>        /lib/libsocket.so.1
        libmtmalloc.so.1 =>      /usr/lib/libmtmalloc.so.1
        libnsl.so.1 =>   /lib/libnsl.so.1
        libm.so.2 =>     /lib/libm.so.2
        libc.so.1 =>     /lib/libc.so.1
        libgcc_s.so.1 =>         /usr/local/lib/libgcc_s.so.1
        libaio.so.1 =>   /lib/libaio.so.1
        libmd5.so.1 =>   /lib/libmd5.so.1
        libmp.so.2 =>    /lib/libmp.so.2
        libscf.so.1 =>   /lib/libscf.so.1
        libdoor.so.1 =>  /lib/libdoor.so.1
        libuutil.so.1 =>         /lib/libuutil.so.1
        /platform/SUNW,Sun-Fire-V245/lib/libc_psr.so.1
        /platform/SUNW,Sun-Fire-V245/lib/libmd5_psr.so.1

ssmirnova@sol10-sparc-c ~/sol10-sparc-c/DBD-mysql-4.005
$make test
make: Warning: File `blib/arch/auto/DBD/mysql/mysql.so' has modification time 2.5 s in the
future
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/00base.............ok 3/5install_driver(mysql) failed: Can't load
'/users/ssmirnova/sol10-sparc-c/DBD-mysql-4.005/blib/arch/auto/DBD/mysql/mysql.so' for
module DBD::mysql: ld.so.1: perl: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may
not be dlopen()'ed at /usr/perl5/5.8.4/lib/sun4-solaris-64int/DynaLoader.pm line 230.
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
....
[4 Dec 2007 16:59] Kent Boortz
An unconditional configure test if "libmtmalloc" exists
was added, and if it does, it is used for linking all
objects. This caused regression in 5.1.21, 5.1.22 and
6.0.3.
[4 Dec 2007 20:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/39242

ChangeSet@1.2628, 2007-12-04 20:27:08+01:00, kent@mysql.com +1 -0
  configure.in:
    Removed the auto detection and use of Solaris "libmtmalloc", as it
    cause regression on bug#18322. The code removed also prevented
    a build without using this library. Users can still compile with
    "libmtmalloc", if configuring with "--with-mysqld-libs=-lmtmalloc"
[5 Dec 2007 0:55] Kent Boortz
Note that this bug has went from "closed" to
"verified" several times.

Change will be in 5.1.23 and 6.0.5.
[5 Dec 2007 19:19] Paul DuBois
Noted in 5.1.23, 6.0.5 changelogs.
[11 Dec 2007 15:51] Bugs System
Pushed into 5.1.23-rc
[11 Dec 2007 15:51] Bugs System
Pushed into 6.0.5-alpha