Bug #48524 Loading innodb_plugin cause gcc-3.x compiled server crash.
Submitted: 4 Nov 2009 8:21 Modified: 9 Nov 2009 18:21
Reporter: Hiroaki Kawai (OCA) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: InnoDB Plugin storage engine Severity:S3 (Non-critical)
Version:5.1.40 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Contribution
Triage: Needs Triage: D3 (Medium)

[4 Nov 2009 8:21] Hiroaki Kawai
Description:
gcc 3.3 and higher supports 'visibility' function attribute, so storage/innodb_plugin/include/univ.i should be patched like this. Without this patch, in gcc 3.x systems mysqld will fail loading innodb_plugin and get signal 11 (mysqld server crash). I tested on my server.

$ uname -a
Linux serv 2.6.9-89.0.11.ELsmp #1 SMP Tue Sep 15 07:08:59 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release 
CentOS release 4.8 (Final)

How to repeat:
Compile mysql 5.1.40 from source with configure option --with-plugins=max, and run mysqld with --ignore-builtin-innodb --plugin-load=innodb=ha_innodb_plugin.so.

Suggested fix:
--- old/mysql-5.1.40/storage/innodb_plugin/include/univ.i       2009-10-07 02:50:22.000000000 +0900
+++ new/mysql-5.1.40/storage/innodb_plugin/include/univ.i       2009-11-04 17:07:05.000000000 +0900
@@ -251,7 +251,7 @@
 
 /* Linkage specifier for non-static InnoDB symbols (variables and functions)
 that are only referenced from within InnoDB, not from MySQL */
-#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(UNIV_HOTBACKUP)
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && !defined(UNIV_HOTBACKUP)
 # define UNIV_INTERN __attribute__((visibility ("hidden")))
 #else
 # define UNIV_INTERN
[4 Nov 2009 10:43] Miguel Solorzano
I couldn't repeat on Ubuntu 9.10 64-bit with server built with current source and gcc:

miguel@quetzalli:~/dbs$ gcc --version
gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.

miguel@quetzalli:~/dbs$ 5.1crash/libexec/mysqld --ignore-builtin-innodb --plugin-load=innodb=ha_innodb_plugin.so
091104  8:38:24 [Note] Plugin 'FEDERATED' is disabled.
091104  8:38:24 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
091104  8:38:25  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
091104  8:38:25  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
091104  8:38:25  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
091104  8:38:25 InnoDB Plugin 1.0.5 started; log sequence number 0
091104  8:38:25 [Note] Event Scheduler: Loaded 0 events
091104  8:38:25 [Note] 5.1crash/libexec/mysqld: ready for connections.
Version: '5.1.41'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[4 Nov 2009 11:45] Hiroaki Kawai
> gcc (Ubuntu 4.4.1-4ubuntu8) 4.4.1
Of cource, gcc 4.x compiled binary will work fine. gcc-3.x compiled server will crash.
[5 Nov 2009 15:51] Valeriy Kravchuk
I'd say this is not a bug formally. Our manual (http://dev.mysql.com/doc/refman/5.1/en/innodb.html) clearly says:

"If you use gcc, InnoDB Plugin cannot be compiled with gcc  3.x; you must use gcc 4.x instead."
[5 Nov 2009 16:41] Hiroaki Kawai
You say it's documented so it is not a BUG in that word. Ok I saw it now. But reading the source code, gcc 3.3 and higher which supports 'visibility' attribute, will be able to compile the plugin actually. IMHO, letting people compile this plugin with gcc 3.3.x, 3.4.x is not so bad.

I already suggested a patch, and I'd suggest following points:
1. Apply the patch and rewrite the documentation
2. Make configure script more clever to detect gcc version or innobase/innodb_plugin conflict and raise warning if condition is not satisfied
3. Move InnoDB compilation note into "2.3 MySQL Installation Using a Source Distribution"