Bug #59888 debug assertion/crash when attempt to create spatial index on char > 31 bytes
Submitted: 2 Feb 2011 10:28 Modified: 6 Apr 2011 1:39
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S1 (Critical)
Version:5.1.56 OS:Any
Assigned to: CPU Architecture:Any
Tags: crash, regression, spatial
Triage: Triaged: D1 (Critical)

[2 Feb 2011 10:28] Shane Bester
Description:
Version: '5.1.56-valgrind-max-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
[New Thread 0x7ffff40a3710 (LWP 304)]
safe_mutex: Trying to unlock mutex that wasn't locked at mi_create.c, line 835
            Last used at mi_open.c, line: 106

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff40a3710 (LWP 304)]
0x00000030e14329a5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64     return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  in raise at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  in abort at abort.c:92
#2  in safe_mutex_unlock at thr_mutex.c:182
#3  in mi_create at mi_create.c:835
#4  in ha_myisam::create at ha_myisam.cc:1969
#5  in handler::ha_create at handler.cc:3421
#6  in ha_create_table at handler.cc:3628
#7  in rea_create_table at unireg.cc:421
#8  in mysql_create_table_no_lock at sql_table.cc:3979
#9  in mysql_alter_table at sql_table.cc:7227
#10 in mysql_execute_command at sql_parse.cc:2855
#11 in mysql_parse at sql_parse.cc:6075
#12 in dispatch_command at sql_parse.cc:1261
#13 in do_command at sql_parse.cc:889
#14 in handle_one_connection at sql_connect.cc:1149
#15 in start_thread at pthread_create.c:301
#16 in clone at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

pretty sure this is a recent regression in 5.1, else i'd have seen it long ago.

How to repeat:
#on full debug build of 5.1 bzr:

drop table if exists `t1`;
create table `t1`(`a` char(32) not null)default charset=latin1 engine=myisam;
create spatial index `i` on `t1`(`a`);
[2 Feb 2011 10:47] Valeriy Kravchuk
mysql-5.5 is NOT affected:

openxs@ubuntu:/home2/openxs/dbs/5.5$ bin/mysql --no-defaults -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
Server version: 5.5.10-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists `t1`;
Query OK, 0 rows affected (0.00 sec)

mysql> create table `t1`(`a` char(32) not null)default charset=latin1 engine=myisam;
Query OK, 0 rows affected (0.04 sec)

mysql> create spatial index `i` on `t1`(`a`);
ERROR 1687 (42000): A SPATIAL index may only contain a geometrical type column
[2 Feb 2011 10:50] Valeriy Kravchuk
Verified with current mysql-5.1 on 32-bit Ubuntu 10.04:

openxs@ubuntu:~/dbs/5.1$ bin/mysql --no-defaults -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
Server version: 5.1.56-valgrind-max-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table if exists `t1`;
Query OK, 0 rows affected (5.76 sec)

mysql> create table `t1`(`a` char(32) not null)default charset=latin1 engine=myisam;
Query OK, 0 rows affected (0.07 sec)

mysql> create spatial index `i` on `t1`(`a`);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 110202 12:48:45 mysqld_safe Number of processes running now: 0
110202 12:48:45 mysqld_safe mysqld restarted

mysql> exit
Bye
openxs@ubuntu:~/dbs/5.1$ tail -80 var/ubuntu.err 
...
110202 12:48:27 [Note] /home/openxs/dbs/5.1/libexec/mysqld: ready for connections.
Version: '5.1.56-valgrind-max-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
safe_mutex: Trying to unlock mutex that wasn't locked at mi_create.c, line 835
            Last used at mi_open.c, line: 106
110202 12:48:45 - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8384512
read_buffer_size=131072
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 337768 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0xa3024a8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xb445f38c thread_stack 0x30000
/home/openxs/dbs/5.1/libexec/mysqld(my_print_stacktrace+0x26)[0x85fedd2]
/home/openxs/dbs/5.1/libexec/mysqld(handle_segfault+0x2b9)[0x827c24e]
[0x3bc400]
/lib/tls/i686/cmov/libc.so.6(abort+0x182)[0x25aa82]
/home/openxs/dbs/5.1/libexec/mysqld(safe_mutex_unlock+0x77)[0x860a2ec]
/home/openxs/dbs/5.1/libexec/mysqld(mi_create+0x24e6)[0x85a308d]
/home/openxs/dbs/5.1/libexec/mysqld(_ZN9ha_myisam6createEPKcP8st_tableP24st_ha_create_information+0x39e)[0x85b23fa]
/home/openxs/dbs/5.1/libexec/mysqld(_ZN7handler9ha_createEPKcP8st_tableP24st_ha_create_information+0x3a)[0x83c46a4]
/home/openxs/dbs/5.1/libexec/mysqld(_Z15ha_create_tableP3THDPKcS2_S2_P24st_ha_create_informationb+0x1fc)[0x83c4dff]
/home/openxs/dbs/5.1/libexec/mysqld(_Z16rea_create_tableP3THDPKcS2_S2_P24st_ha_create_informationR4ListI12Create_fieldEjP6st_keyP7handler+0x260)[0x83714d1]
/home/openxs/dbs/5.1/libexec/mysqld(_Z26mysql_create_table_no_lockP3THDPKcS2_P24st_ha_create_informationP10Alter_infobj+0x104b)[0x83eacb8]
/home/openxs/dbs/5.1/libexec/mysqld(_Z17mysql_alter_tableP3THDPcS1_P24st_ha_create_informationP10TABLE_LISTP10Alter_infojP8st_orderb+0x20e1)[0x83f4494]
/home/openxs/dbs/5.1/libexec/mysqld(_Z21mysql_execute_commandP3THD+0x2102)[0x828fe81]
/home/openxs/dbs/5.1/libexec/mysqld(_Z11mysql_parseP3THDPcjPPKc+0x265)[0x829a2bf]
/home/openxs/dbs/5.1/libexec/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xbee)[0x828c001]
/home/openxs/dbs/5.1/libexec/mysqld(_Z10do_commandP3THD+0x26c)[0x828b109]
/home/openxs/dbs/5.1/libexec/mysqld(handle_one_connection+0x159)[0x82892aa]
/lib/tls/i686/cmov/libpthread.so.0(+0x596e)[0xd1196e]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e)[0x2faa4e]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0xa32f528): create spatial index `i` on `t1`(`a`)
Connection ID (thread ID): 1
Status: NOT_KILLED
[9 Mar 2011 7:35] Shane Bester
i wonder if the fix for this bug also fixed this crasher (on release build):

---
drop table if exists `g4`;
create table `g4` (`a` binary(32) not null,spatial key (`a`)) engine=myisam;
insert into `g4` values ("#");
---

Version: '5.1.56-community'  socket: ''  port: 3306  MySQL Community Server (GPL)
110309  9:25:53 - mysqld got exception 0xc0000005 ;
mysqld.exe!sp_get_geometry_mbr()[sp_key.c:201]
mysqld.exe!sp_mbr_from_wkb()[sp_key.c:113]
mysqld.exe!sp_make_key()[sp_key.c:58]
mysqld.exe!_mi_make_key()[mi_key.c:66]
mysqld.exe!mi_write()[mi_write.c:126]
mysqld.exe!ha_myisam::write_row()[ha_myisam.cc:788]
mysqld.exe!handler::ha_write_row()[handler.cc:4673]
mysqld.exe!write_record()[sql_insert.cc:1604]
mysqld.exe!mysql_insert()[sql_insert.cc:835]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3254]
mysqld.exe!mysql_parse()[sql_parse.cc:6079]
mysqld.exe!dispatch_command()[sql_parse.cc:1263]
mysqld.exe!do_command()[sql_parse.cc:893]
mysqld.exe!handle_one_connection()[sql_connect.cc:1149]
mysqld.exe!pthread_start()[my_winthread.c:85]
mysqld.exe!_callthreadstart()[thread.c:293]

because it's not repeatable in 5.1.57 from bzr.
[6 Apr 2011 1:39] Paul Dubois
Noted in 5.1.57, 5.5.11, 5.6.2 changelogs.

Attempting to create a spatial index on a CHAR column longer than 31
bytes led to an assertion failure if the server was compiled with
safemutex support. 

CHANGESET - http://lists.mysql.com/commits/131299