Bug #46587 archive storage engine headers don't include my_global.h first
Submitted: 6 Aug 2009 17:53 Modified: 28 Apr 2010 1:57
Reporter: Mark Callaghan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Archive storage engine Severity:S3 (Non-critical)
Version:5.4, 5.5.3-m3 OS:Any
Assigned to: Sergey Vojtovich CPU Architecture:Any
Tags: archive, include

[6 Aug 2009 17:53] Mark Callaghan
Description:
I think that storage/archive/azio.h has include files in the wrong order. It includes <zlib.h> before "my_global.h". That makes compiles in 5.4 fail with:

Making all in archive
/m/bld/mysql-azalea-perfschema/storage/archive
make[2]: Entering directory `/m/bld/mysql-azalea-perfschema/storage/archive'
if g++ -DHAVE_CONFIG_H -I. -I. -I../../include  -DHAVE_MYSQL_CONFIG_H -I../../include -I../../regex -I../../sql -I../../zlib   -g -O2   -fno-implicit-templates -fno-exceptions -fno-rtti  -MT ha_archive.o -MD -MP -MF ".deps/ha_archive.Tpo" -c -o ha_archive.o ha_archive.cc; \
then mv -f ".deps/ha_archive.Tpo" ".deps/ha_archive.Po"; else rm -f ".deps/ha_archive.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I../../include  -DHAVE_MYSQL_CONFIG_H -I../../include -I../../regex -I../../sql -I../../zlib   -g -O2   -DUNIV_LINUX -MT azio.o -MD -MP -MF ".deps/azio.Tpo" -c -o azio.o azio.c; \
then mv -f ".deps/azio.Tpo" ".deps/azio.Po"; else rm -f ".deps/azio.Tpo"; exit 1; fi
In file included from ../../include/my_pthread.h:653,
                 from ../../include/my_sys.h:36,
                 from azio.h:48,
                 from azio.c:14:
../../include/mysql/psi/mysql_thread.h:100: error: syntax error before 'pthread_rwlock_t'
../../include/mysql/psi/mysql_thread.h:100: warning: no semicolon at end of struct or union
../../include/mysql/psi/mysql_thread.h:107: error: syntax error before '}' token
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_init':
../../include/mysql/psi/mysql_thread.h:602: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:602: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:610: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_destroy':
../../include/mysql/psi/mysql_thread.h:617: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:619: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:620: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:623: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_rdlock':
../../include/mysql/psi/mysql_thread.h:636: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:637: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:641: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_wrlock':
../../include/mysql/psi/mysql_thread.h:659: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:660: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:664: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_tryrdlock':
../../include/mysql/psi/mysql_thread.h:682: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:684: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:687: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_trywrlock':
../../include/mysql/psi/mysql_thread.h:705: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:707: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:710: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h: In function 'inline_mysql_rwlock_unlock':
../../include/mysql/psi/mysql_thread.h:724: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:726: error: dereferencing pointer to incomplete type
../../include/mysql/psi/mysql_thread.h:728: error: dereferencing pointer to incomplete type

How to repeat:
./configure --enable-thread-safe-client --with-plugins=max-no-ndb --without-fast-mutexes --with-extra-charsets=all --with-plugin-perfschema
make

Suggested fix:
I saw this error a long time ago when backporting the --with-fast-mutexes option to 5.0. Monty's response was that my_global.h should always be included first. That is important when redefining pthread structs as done by the perfschema code.

The current order is:

>>>
#include "my_global.h"
#include "my_sys.h"
#include <zlib.h>
>>>

And I think they should be in this order:
>>>
#include "my_global.h"
#include "my_sys.h"
#include <zlib.h>
>>>
[26 Aug 2009 18:11] MySQL Verification Team
Thank you for the bug report.

/* We currently allow this on all platforms */
#define AZIO_AIO

#include <zlib.h>
#include "my_global.h"
#include "my_sys.h"

#include <my_dir.h>
[22 Mar 2010 15:20] 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/104012

3126 Joerg Bruehe	2010-03-22
      Fixes related to bug#46587:
      archive storage engine headers don't include my_global.h first
      
      
      During the build of 5.5.3-m3 on older Linux platforms
      (kernels 2.4 or early 2.6),
      the symptom described in the bug report occurred both
      in the "archive" and in the "innobase" storage engine.
      
      This change is the patch proposed in that bug report,
      and a similar one in innobase, that latter is aligned
      with Vasil Dimov of Innobase, the original author.
[22 Mar 2010 15:29] Joerg Bruehe
This bug affected the release build of 5.5.3 on early Linux platforms (kernels 2.4 and early 2.6).

Applying the proposed patch solved it.

So this fix will be included in the 5.5.3 release.

Please change status back to "patch pending" after documenting it for 5.5.3:
This fix is not yet reviewed formally,
it should be either accepted as proposed by the reported or improved.
[23 Mar 2010 15:50] Paul DuBois
Not in any released version.

Resetting report to Patch Pending per Joerg's comment.
[15 Apr 2010 9:34] 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/105702

3118 Sergey Vojtovich	2010-04-15
      BUG#46587 - archive storage engine headers don't include
                  my_global.h first
      
      We may end up with a compilation failure on certain platforms
      because zlib.h is included before my_global.h.
      
      Fixed by moving zlib.h inclusion down after my_global.h.
     @ storage/archive/azlib.h
        zlib.h must be included after my_global.h.
[27 Apr 2010 9:44] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100427094135-5s49ecp3ckson6e2) (version source revid:alik@sun.com-20100427093843-uekr85qkd7orx12t) (merge vers: 6.0.14-alpha) (pib:16)
[27 Apr 2010 9:48] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100427093804-a2k3rrjpwu5jegu8) (version source revid:alik@sun.com-20100427093804-a2k3rrjpwu5jegu8) (merge vers: 5.5.5-m3) (pib:16)
[27 Apr 2010 9:51] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100427094036-38frbg3famdlvjup) (version source revid:alik@sun.com-20100427093825-92wc8b22d4yg34ju) (pib:16)
[28 Apr 2010 1:57] Paul DuBois
Not in any released version. No changelog entry needed.