Bug #27741 udf test fails on AIX < 5.3
Submitted: 10 Apr 2007 22:02 Modified: 11 Jul 2007 22:09
Reporter: Peter O'Gorman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.0.38 OS:IBM AIX (AIX4.3,5.1,5.2)
Assigned to: Martin Hansson CPU Architecture:Any
Tags: AIX, Contribution, Tests, udf

[10 Apr 2007 22:02] Peter O'Gorman
Description:
The udf test fails on AIX because it can not find the library udf_example.so. It can not find the library because AIX until 5.3 does not look at LD_LIBRARY_PATH when doinf dlopen() it looks at the env var LIBPATH.

How to repeat:
build and run the tests on AIX < 5.3

Suggested fix:
Note that I added SHLIB_PATH there also, it is the shared library path environment variable used on hp-ux.

Index: mysql-test/mysql-test-run.pl
===================================================================
--- mysql-test/mysql-test-run.pl.orig   2007-03-20 19:12:13.000000000 +0000
+++ mysql-test/mysql-test-run.pl        2007-04-10 21:08:31.923193000 +0000
@@ -1738,6 +1738,16 @@
                                  split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
   mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
 
+  $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
+                                 $ENV{'SHLIB_PATH'} ?
+                                 split(':', $ENV{'SHLIB_PATH'}) : ());
+  mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
+
+  $ENV{'LIBPATH'}= join(":", @ld_library_paths,
+                                 $ENV{'LIBPATH'} ?
+                                 split(':', $ENV{'LIBPATH'}) : ());
+  mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
+
 
   # --------------------------------------------------------------------------
   # Also command lines in .opt files may contain env vars
[16 Apr 2007 8:14] Sveta Smirnova
Thank you for the report.

Verified as described.
[3 May 2007 12:33] Martin Hansson
You didn't mention how you built this, but let me give you some background:

On most Unix systems, files with the extension '.so' are shared libraries and so for example on Linux udf_example.c gets compiled into udf_example.o and this is contained in both udf_example.a and udf_example.so. The '.a' extension tells Linux that this is a static library, so there need be a '.so' file as well, in
order to load dynamically.

On AIX, there doesn't have to be a '.so' file, since a '.a' file can hold dynamically loaded things as well. From version 5.0.40 on, however, the MySQL binaries are built to have '.so' libraries.

Do you really mean that the udf test fails? Or do you mean this result:

udf [ skipped ] Test requires: 'have_udf_example'
[3 May 2007 12:46] Sveta Smirnova
I really mean udf test fails.
[3 May 2007 14:01] Peter O'Gorman
We built mysql with -brtl in LDFLAGS. The -brtl flag enables runtime linking and causes GNU libtool to build shared libraries with the .so extension.
[16 May 2007 15:04] 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/26843

ChangeSet@1.2470, 2007-05-16 17:19:15+02:00, mhansson@dl145s.mysql.com +1 -0
  bug#27741: udf test fails on AIX < 5.3
  
  problem #1: udf_example.so does not get built on AIX
  
  solution#1: build it yourself using
  cd sql; gcc  -g -I ../include/ -I /usr/include/ -lpthread  \
  -shared -o udf_example.so udf_example.c; mv udf_example.so \
  .libs/ 
  
  problem#2 (the bug): udf_example fails because it does not
  recognize the variable LD_LIBRARY_PATH when doing dl_open(),
  it looks at LIBPATH
  
  solution#2: add the library path to LIBPATH
  
  problem#3: udf_example returns the wrong result length since 
  it relies on strmov to return a pointer to the end of the 
  string that it copies. On AIX builds, where m_string.h is not
  included (m_string defines a macro expanding strmov to stpcpy),
  there is a macro expanding strmov to strcpy, which returns a 
  pointer to the first character.
  
  solution#3: define strmov as stpcpy.
  
  problem#4: #2 applies on hp-ux as well, but this platform
  looks at SHLIB_PATH
  
  solution#4: add the library path to SHLIB_PATH
[16 May 2007 15:15] 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/26844

ChangeSet@1.2470, 2007-05-16 17:30:02+02:00, mhansson@dl145s.mysql.com +2 -0
  bug#27741: udf test fails on AIX < 5.3
  
  problem #1: udf_example.so does not get built on AIX
  
  solution#1: build it yourself using
  cd sql; gcc  -g -I ../include/ -I /usr/include/ -lpthread  \
  -shared -o udf_example.so udf_example.c; mv udf_example.so \
  .libs/ 
  
  problem#2 (the bug): udf_example fails because it does not
  recognize the variable LD_LIBRARY_PATH when doing dl_open(),
  it looks at LIBPATH
  
  solution#2: add the library path to LIBPATH
  
  problem#3: udf_example returns the wrong result length since 
  it relies on strmov to return a pointer to the end of the 
  string that it copies. On AIX builds, where m_string.h is not
  included (m_string defines a macro expanding strmov to stpcpy),
  there is a macro expanding strmov to strcpy, which returns a 
  pointer to the first character.
  
  solution#3: define strmov as stpcpy.
  
  problem#4: #2 applies on hp-ux as well, but this platform
  looks at SHLIB_PATH
  
  solution#4: add the library path to SHLIB_PATH
[23 May 2007 18:02] Joerg Bruehe
Sent a patch review by mail, there are still open questions.
[29 May 2007 9:35] 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/27545

ChangeSet@1.2470, 2007-05-29 11:51:49+02:00, mhansson@dl145s.mysql.com +2 -0
  bug#27741: udf test fails on AIX < 5.3
  
  problem #1: udf_example.so does not get built on AIX
  
  solution#1: build it yourself using
  cd sql; gcc  -g -I ../include/ -I /usr/include/ -lpthread  \
  -shared -o udf_example.so udf_example.c; mv udf_example.so \
  .libs/ 
  
  problem#2 (the bug): udf_example fails because it does not
  recognize the variable LD_LIBRARY_PATH when doing dl_open(),
  it looks at LIBPATH
  
  solution#2: add the library path to LIBPATH
  
  problem#3: udf_example returns the wrong result length since 
  it relies on strmov to return a pointer to the end of the 
  string that it copies. On AIX builds, where m_string.h is not
  included (m_string defines a macro expanding strmov to stpcpy),
  there is a macro expanding strmov to strcpy, which returns a 
  pointer to the first character.
  
  solution#3: define strmov as stpcpy.
  
  problem#4: #2 applies on hp-ux as well, but this platform
  looks at SHLIB_PATH
  
  solution#4: added the library path to SHLIB_PATH
[31 May 2007 12:06] 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/27804

ChangeSet@1.2490, 2007-05-31 14:22:21+02:00, mhansson@dl145s.mysql.com +2 -0
  bug#27741: udf test fails on AIX < 5.3
  
  problem #1: udf_example.so does not get built on AIX
  
  solution#1: build it yourself using
  cd sql; gcc  -g -I ../include/ -I /usr/include/ -lpthread  \
  -shared -o udf_example.so udf_example.c; mv udf_example.so \
  .libs/ 
  
  problem#2 (the bug): udf_example fails because it does not
  recognize the variable LD_LIBRARY_PATH when doing dl_open(),
  it looks at LIBPATH
  
  solution#2: add the library path to LIBPATH
  
  problem#3: udf_example returns the wrong result length since 
  it relies on strmov to return a pointer to the end of the 
  string that it copies. On AIX builds, where m_string.h is not
  included (m_string defines a macro expanding strmov to stpcpy),
  there is a macro expanding strmov to strcpy, which returns a 
  pointer to the first character.
  
  solution#3: define strmov as stpcpy.
  
  problem#4: #2 applies on hp-ux as well, but this platform
  looks at SHLIB_PATH
  
  solution#4: added the library path to SHLIB_PATH
[4 Jun 2007 21:21] Bugs System
Pushed into 5.1.20-beta
[4 Jun 2007 21:23] Bugs System
Pushed into 5.0.44
[11 Jul 2007 22:09] Paul DuBois
Noted in 5.0.44, 5.1.20 changelogs.

On some systems, udf_example.c returned an incorrect result length.
Also on some systems, mysql-test-run.pl could not find the shared 
object built from udf_example.c.