Bug #9175 seg fault on 'mysqldump --single-transaction --tab mysql nonexistent'
Submitted: 14 Mar 2005 23:02 Modified: 26 Apr 2005 2:17
Reporter: Tim Smith
Status: Closed
Category:Client Severity:S3 (Non-critical)
Version:4.1.11 OS:Any (any)
Assigned to: Reggie Burnett Target Version:

[14 Mar 2005 23:02] Tim Smith
Description:
15:00 ~/m/41/m$ mysqldump --single-transaction --tab=/tmp/foo/ mysql nonexistent
zsh: segmentation fault (core dumped)  mysqldump --single-transaction --tab=/tmp/foo/
mysql nonexistent

However, it works to pass an existing table:

14:59 ~/m/41/m$ mysqldump --single-transaction --tab=/tmp/foo/ mysql user
15:00 ~/m/41/m$

I tested on FreeBSD 5.4, recent 4.1.11-pre code from BK.

How to repeat:

mysqldump --single-transaction --tab=/tmp/foo/ mysql nonexistent
[15 Mar 2005 20:57] Guilhem Bichot
For a simpler testcase:
(gdb) r --lock-tables=0 mysql non
Starting program: /home/mysql_src/mysql-4.1-clean/client/.libs/lt-mysqldump
--lock-tables=0 mysql non
-- MySQL dump 10.9
--
-- Host: localhost    Database: mysql
-- ------------------------------------------------------
-- Server version       4.0.23-debug-log
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

Program received signal SIGSEGV, Segmentation fault.
0x0804e246 in get_actual_table_name (old_table_name=0xbffff300 "non",
new_table_name=0xbfffeed0 "\f\177", buf_size=64)
    at mysqldump.c:2120
2120      strmake(new_table_name, row[0], buf_size-1);
"row" is 0 (because the SHOW TABLES query returns nothing).

If lock_tables is set, mysqldump detects the non-existency during LOCK TABLES.

mysqldump 4.0 does not have the problem.
[16 Mar 2005 22:51] Guilhem Bichot
Reggie, this is your get_actual_table_name(): you may want to detect when the SHOW TABLES
LIKE returns no rows (inexistent table) and return info to the caller (so that caller
skips dumping the table), instead of dereferencing "row" which is a null pointer. Thanks!!
[28 Mar 2005 21:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23416
[31 Mar 2005 16:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23531
[1 Apr 2005 18:19] Reggie Burnett
Fixed in 4.1.11 and 5.0.4.
[1 Apr 2005 19:21] Reggie Burnett
err, correcton.  I think this bug will appear in 5.0.4 and 4.1.12
[26 Apr 2005 2:17] Paul DuBois
Noted in 4.1.12, 5.0.4 changelogs.