Bug #21749 Compile error because of double "#define"
Submitted: 21 Aug 2006 11:15 Modified: 31 Aug 2006 19:35
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.0 + 5.1 OS:IBM AIX (AIX)
Assigned to: Magnus Blåudd CPU Architecture:Any

[21 Aug 2006 11:15] Joerg Bruehe
Description:
Detected during test builds of 5.0.25 (pre) and 5.1.12-beta (pre).

A change to "configure.in" (done in June, but merged only recently) now causes "my_config.h" to contain unprotected lines
   #define DBUG_OFF
or
   #define DBUG_ON
(depending on the build variant).

Via inclusion in "my_global.h", this gets into all source modules.

Source "mysys/thr_alarm.c" starts with these lines (after the license header):
   /* To avoid problems with alarms in debug code, we disable DBUG here */
   #undef DBUG_OFF
   #define DBUG_OFF
   #include <my_global.h>
   ...

As a recult, the C compiler on AIX sees a double definition of "DBUG_OFF" and considers this a fatal error.

How to repeat:
Build on AIX.

Suggested fix:
Longer term:
1) Protect "my_config.h" against double inclusion,
2) change "mysys/thr_alarm.c" to this:
      #include <my_config.h>
      /* To avoid problems with alarms in debug code, we disable DBUG here */
      #ifdef DBUG_ON
      #undef DBUG_ON
      #define DBUG_OFF
      #endif
      #include <my_global.h>
      ...

Short term:
1) Use some symbol which "my_config.h" will *always* define to some value,
   like "VERSION" or one of the "SIZEOF_*" symbols,
   in "my_global.h" to do the double inclusion check:
      #ifndef VERSION
      #include <my_config.h>
      #endif
2) as above.

I am just doing a test build, using approach 2.
[21 Aug 2006 13:03] Joerg Bruehe
Proposed patch to current 5.0 to fix bug#21749

Attachment: patch-21749 (application/octet-stream, text), 2.41 KiB.

[22 Aug 2006 11:51] 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/10721

ChangeSet@1.2248, 2006-08-22 13:51:17+02:00, msvensson@neptunus.(none) +3 -0
  Bug#21749 Compile error because of double "#define"
   - Define DONT_USE_DBUG in thr_alarm-.c and thr_lock.c to make my_global.h turn off DBUG features for those two files.
[24 Aug 2006 8:17] 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/10813

ChangeSet@1.2248, 2006-08-24 09:15:00+02:00, msvensson@neptunus.(none) +3 -0
  Bug#21749 Compile error because of double "#define"
   - Define DONT_USE_DBUG in thr_alarm-.c and thr_lock.c to make my_global.h turn off DBUG features for those two files.
[24 Aug 2006 10:16] Magnus Blåudd
Patch for bug#19517 will be reverted.
[24 Aug 2006 14:49] Magnus Blåudd
Pushed to mysql-5.0-maint
[31 Aug 2006 12:32] Magnus Blåudd
Pushed to 5.0.25
[31 Aug 2006 19:35] Paul DuBois
No changelog entry needed.
[12 Oct 2006 17:48] 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/13627

ChangeSet@1.2314, 2006-10-12 19:43:47+02:00, kent@mysql.com +3 -0
  thr_alarm.c, thr_lock.c, my_global.h:
    Avoid multiple define of DBUG_OFF (bug#21749)