Bug #975 InnoDB assertion failure on Solaris when building with Sun compilers
Submitted: 31 Jul 2003 23:37 Modified: 1 Aug 2003 2:41
Reporter: Alex Kiernan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:4.0.14 OS:Solaris (Solaris)
Assigned to: CPU Architecture:Any

[31 Jul 2003 23:37] Alex Kiernan
Description:
When built with the Sun compilers (cc: Forte Developer 7 C 5.4 2002/03/09), log_group_calc_lsn_offset fails at startup with an assertion failure:

offset <= 0xFFFFFFFF

It looks like its a compiler bug with respect to sign extension (if you read the generated code, its sign extending the constant to be -1LL)

How to repeat:
CC=/opt/SUNWspro/bin/cc CFLAGS="-fast -g -xs -v -xstrconst -xdepend -xtarget=ultra2 -xarch=v8plusa -xprefetch -mt -D_FORTEC_" LDFLAGS="-xildoff" CXXFLAGS="-fast -g -xs -xtarget=ultra2 -xarch=v8plusa -xprefetch -noex -mt -D_FORTEC_" ./configure --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-openssl --with-libwrap=/usr/sfw 

compile & run - fails on startup

Suggested fix:
Index: mysql/innobase/log/log0log.c
===================================================================
RCS file: /cvsroot/upstream/mysql/innobase/log/log0log.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- mysql/innobase/log/log0log.c        2003/07/18 14:57:42     1.1.1.2
+++ mysql/innobase/log/log0log.c        2003/07/28 20:01:37     1.2
@@ -443,6 +443,8 @@
        ib_longlong     difference;
        ib_longlong     group_size;
        ib_longlong     offset;
+       static const ib_longlong
+                       maxoffset = (((ib_longlong)1 << 32) - 1);
        
        ut_ad(mutex_own(&(log_sys->mutex)));
 
@@ -469,7 +471,7 @@
 
        offset = (gr_lsn_size_offset + difference) % group_size;
 
-       ut_a(offset <= 0xFFFFFFFF);
+       ut_a(offset <= maxoffset);
 
        /* printf("Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
               (ulint)offset,(ulint)gr_lsn_size_offset, (ulint)difference);
[1 Aug 2003 2:41] Heikki Tuuri
Hi!

Thank you for the excellent bug report. I fixed it now to 4.0.15 and 4.1.1.

Regards,

Heikki