Bug #21042 mysql client segfaults on importing a mysqldump export
Submitted: 13 Jul 2006 16:48 Modified: 15 Aug 2006 3:11
Reporter: Kaleb Pederson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.22/5.0BK OS:Linux (Linux/Ubuntu)
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: MySQL, mysqldump

[13 Jul 2006 16:48] Kaleb Pederson
Description:
mysql segfaults on importing a mysqldump file generated with version 4.1.11 of mysql.

I will attached xfile_single_row.dat which is the dump file generated by mysqldump-4.1.11.

I will also attach a resolved stack trace.

How to repeat:
mysqladmin create testdb
mysql -u root -p testdb < xfile_single_row.dat
-- mysql segfaults
[13 Jul 2006 16:49] Kaleb Pederson
mysqldump file

Attachment: xfile_single_row.dat (application/octet-stream, text), 55.85 KiB.

[13 Jul 2006 16:52] Kaleb Pederson
Resolved stack trace

Attachment: resolved_bt.txt (text/plain), 15.14 KiB.

[13 Jul 2006 18:20] MySQL Verification Team
Thank you for the bug report. Verified as described.

(gdb) run  -uroot  testdb < /home/miguel/a/xfile_single_row.dat
Starting program: /home/miguel/dbs/5.0/bin/mysql -uroot  testdb < /home/miguel/a/xfile_single_row.dat
[Thread debugging using libthread_db enabled]
[New Thread 1078081760 (LWP 6479)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1078081760 (LWP 6479)]
0x4036b2a6 in stpcpy () from /lib/tls/libc.so.6
[27 Jul 2006 9:44] Magnus Blåudd
The mysql program finds "\r" char in the blob and interprets that as a "reconnect" command. Then tries to reconnect with very strange random values from the blob.
[27 Jul 2006 10:26] Magnus Blåudd
Please use mysqldump with --hex-blob option to dump your data in a format that allows the blob to contain any values.

Extract from http://dev.mysql.com/doc/refman/4.1/en/mysqldump.html
> --hex-blob
>
> Dump binary columns using hexadecimal notation (for example, 'abc' becomes
> 0x616263). The affected data types are BINARY, VARBINARY, and BLOB in MySQL 4.1 > and up, and CHAR BINARY, VARCHAR BINARY, and BLOB in MySQL 4.0. This option was > added in MySQL 4.0.23 and 4.1.8.
[27 Jul 2006 10:29] 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/commits/9659
[27 Jul 2006 10:31] Magnus Blåudd
Thanks four your bug report. Found the cause of the segfault as you can see in the attached patch. Unforunately that does not make your problem go away. You need to use the --hex-blob option to mysqldump.
[31 Jul 2006 12:23] 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/commits/9831

ChangeSet@1.2244, 2006-07-31 14:22:32+02:00, msvensson@neptunus.(none) +3 -0
  Bug#21042 mysql client segfaults on importing a mysqldump export
   - Use strmake, that will both protect the buffer and make sure it's terminated by a zero
   - Add test case
[1 Aug 2006 9:43] Magnus Blåudd
Pushed to mysql-5.0-maint
[2 Aug 2006 12:31] Magnus Blåudd
The segfault is fixed, setting it back to "Patch queued".
[3 Aug 2006 16:42] Magnus Blåudd
Pushed to 5.0.25
[3 Aug 2006 16:43] Magnus Blåudd
Pushed to 5.0.25
[3 Aug 2006 17:27] Paul DuBois
Noted in 5.0.25 changelog.

mysql crashed for very long arguments to the connect command.
[14 Aug 2006 20:42] Konstantin Osipov
Merged into 5.1.12
[15 Aug 2006 3:11] Paul DuBois
Noted in 5.1.12 changelog.
[26 Nov 2006 19:13] Sergey Kostyliov
MySQL 5.0.26 fixed a segfault in my case (#19849). Unfortunately "reconnect" problem haven't resolved for me yet.

I use `mysqldump -Q --opt --hex-blog -B $db1 $db2 $db3' mysqldump syntax.
[26 Nov 2006 20:51] Sergey Kostyliov
ERROR 2005 (HY000) at line 5992: Unknown MySQL server host 'пока' (3)
ERROR at line 5992: Can't connect to the server
[26 Nov 2006 21:00] Sergey Kostyliov
It is interesting that this only occures when I use full database dump to restore. I.e. if I'll try to dump tables one by one to the different sql files - all of them will be loaded successfully by mysql after that...
[26 Nov 2006 23:59] Sergey Kostyliov
Sorry for misinformation in my previous comment. Error is related only to one table - I can attach it's dumps (~0.5M) if it will be helpfull for you...

`mysqldump -Q --opt --hex-blog ...' produces an unloadable dump for it while `mysqldump --skip-opt --hex-blog ...' does the job.
[27 Nov 2006 8:24] Valeriy Kravchuk
Bug #19849 was marked as a duplicate of this one.