Bug #21919 Segmentation fault when reporting ER_DUP_ENTRY
Submitted: 30 Aug 2006 8:23 Modified: 22 Oct 2007 11:32
Reporter: Marko Mäkelä Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Errors Severity:S4 (Feature request)
Version:5.1-bk OS:Any (all)
Assigned to: Assigned Account CPU Architecture:Any

[30 Aug 2006 8:23] Marko Mäkelä
Description:
The error message format for ER_DUP_ENTRY in 5.0.25 is as follows:
"Duplicate entry '%-.64s' for key %d"
In 5.1, it has been changed to
"Duplicate entry '%-.64s' for key '%-.64s'"

When earlier versions of MySQL are run with the 5.1 errmsg.sys, they will crash because the integer parameter will be interpreted as a string pointer.

I believe that error message files should be downwards compatible, and http://forge.mysql.com/wiki/Contributing supports this belief.

How to repeat:
Start mysqld 5.0, 4.1, or 4.0 with language=.../mysql-5.1/sql/share/english and watch it crash when an ER_DUP_ENTRY error occurs.

Suggested fix:
Compare the 5.1 errmsg.txt files with those of 4.1 and 5.0, and ensure that the format specifiers match. Introduce new error codes for 5.1 when needed, e.g., ER_DUP_ENTRY2 or something like that.
[30 Aug 2006 9:22] Sveta Smirnova
Thank you for the reasonable feature request.

Problem can be repeated as below:

$libexec/mysqld --defaults-file=support-files/my-small.cnf --skip-networking --basedir=. --datadir=./data --log-error --language=/users/ssmirnova/mysql5.1b/share/mysql/english &

$bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.25-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE `t1` (
    ->   `id` int(11) NOT NULL default '0',
    ->   PRIMARY KEY  (`id`)
    -> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.11 sec)

mysql> insert into t1 values(1),(2),(3);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> insert into t1 values(1);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> \q
Bye
[1]+  Exit 1                  libexec/mysqld --defaults-file=support-files/my-small.cnf --skip-networking --basedir=. --datadir=./data --log-error --language=/users/ssmirnova/mysql5.1b/share/mysql/english
[22 Oct 2007 11:32] Sergei Golubchik
Fixed as bug#28842