Bug #3362 Crash on attempt to insert a record with duplicate primary key value
Submitted: 1 Apr 2004 12:40 Modified: 5 Apr 2004 2:24
Reporter: Sergey Petrunya Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1 OS:
Assigned to: CPU Architecture:Any

[1 Apr 2004 12:40] Sergey Petrunya
Description:
Server crashes on attempt to insert a record with duplicate primary key value.
The crash doesn't depend on table engine. 
The crash happens on current 4.1 repository server, doesn't happen on a 4.1 from about one week ago, and doesn't happen on 5.0.

How to repeat:
--disable_query_log
drop table if exists t1,t2;
--enable_query_log

create table t1
(
  a int primary key,
  b char(10),
);
insert into t1 values (1,'one');
insert into t1 values (2,'two');
insert into t1 values (3,'three');
insert into t1 values (4,'four');

insert into t1 values (1, 'another one');

And watch the server to crash on last query
[1 Apr 2004 12:41] Sergey Petrunya
Here is the stack trace:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 73738 (LWP 12982)]
0x08345ff6 in my_vsnprintf (to=0x4158edbe "", n=276, fmt=0x84d1c4d "s'", ap=0x4158eee4 "\024?XAs?\002@P?\\\bP?\\\b??XA\235j\023\bP?\\\b\001") at my_vsnprintf.c:89
89            plen = (uint) strlen(par);
Current language:  auto; currently c
(gdb) bt
#0  0x08345ff6 in my_vsnprintf (to=0x4158edbe "", n=276, fmt=0x84d1c4d "s'", ap=0x4158eee4 "\024?XAs?\002@P?\\\bP?\\\b??XA\235j\023\bP?\\\b\001") at my_vsnprintf.c:89
#1  0x081a945d in push_warning_printf(THD*, MYSQL_ERROR::enum_warning_level, unsigned, char const*, ...) (thd=0x4158ee00, level=1096347136, code=1265, format=0x4158ee00 "") at sql_error.cc:149
#2  0x0813af29 in Field::set_warning(unsigned, unsigned) (this=0x4158ee00, level=1096347136, code=1265) at field.cc:5762
#3  0x08136a9d in Field_string::store(char const*, unsigned, charset_info_st*) (this=0x4f1, from=0x85a8772 "e", length=11, cs=0xa) at field.cc:4142
#4  0x080e09a0 in Item_string::save_in_field(Field*, bool) (this=0x85a8778, field=0x85cd750) at sql_string.h:80
#5  0x081864ec in fill_record(Field**, List<Item>&, bool) (ptr=0x85a8778, values=@0x4158ee00, ignore_errors=false) at sql_base.cc:2519
#6  0x081a2253 in mysql_insert(THD*, st_table_list*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates) (thd=0x85cd750, table_list=0x85a86b0, fields=@0x859c20c, 
    values_list=@0x859c224, update_fields=@0x859c078, update_values=@0x859c218, duplic=DUP_ERROR) at sql_insert.cc:294
#7  0x0816886e in mysql_execute_command(THD*) (thd=0x859bf20) at sql_parse.cc:2603
#8  0x0816bb3f in mysql_parse(THD*, char*, unsigned) (thd=0x859bf20, inBuf=0x859bf30 "\001", length=40) at sql_parse.cc:3950
#9  0x0816599e in dispatch_command(enum_server_command, THD*, char*, unsigned) (command=COM_QUERY, thd=0x859bf20, packet=0x85a4609 "insert into t1 values (1, 'another one')", packet_length=41)
    at sql_parse.cc:1449
#10 0x08165303 in do_command(THD*) (thd=0x859bf20) at sql_parse.cc:1265
#11 0x08164844 in handle_one_connection (arg=0x4158ee00) at sql_parse.cc:1015
#12 0x40028941 in pthread_start_thread () from /lib/i686/libpthread.so.0
#13 0x40028a45 in pthread_start_thread_event () from /lib/i686/libpthread.so.0
(gdb) frame #8
Invalid character '#' in expression.
(gdb) frame 8
#8  0x0816bb3f in mysql_parse(THD*, char*, unsigned) (thd=0x859bf20, inBuf=0x859bf30 "\001", length=40) at sql_parse.cc:3950
3950              mysql_execute_command(thd);
Current language:  auto; currently c++
[2 Apr 2004 3:10] Heikki Tuuri
Sergey,

double-check that you are using the correct errmsg.txt and errmsg.sys for the mysqld version you are running!

The crash very much looks like the error printf function is trying to use a wrong error format string to print the error message.

Regards,

Heikki
[2 Apr 2004 13:29] MySQL Verification Team
I tested a Windows 4.1.2 server 1 day older without to repeat the
behavior reported.
[5 Apr 2004 2:24] Sergey Petrunya
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

As Heikki suggested, the problem was caused by incorrect message files.