Bug #25344 Segmentation violation when try to run the perror utility
Submitted: 31 Dec 2006 16:42 Modified: 15 Feb 2007 4:41
Reporter: Joerg Behrens Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S1 (Critical)
Version:4.1.22 OS:Other (IRIX 6.5.30)
Assigned to: Magnus BlÄudd CPU Architecture:Any
Tags: core, IRIX, perror, segfault

[31 Dec 2006 16:42] Joerg Behrens
Description:
When try to run the perror programm with a parameter is just segfaults. Calling without a parameter it returns version info and usage of the programm. It doesnt matter which errorcode is used.

The same happens on older versions like 4.1.5, 5.0.24 but *not* with 5.0.27

Expected result:
[o2k]:/tmp/mysql-5.0.27 $ bin/perror 12
OS error code  12:  Not enough space

[o2k]:/ $ uname -Ra
IRIX64 o2k 6.5 6.5.30m 07202013 IP27
[o2k]:/ $ cc -v    
MIPSpro Compilers: Version 7.4.4m

$ ./configure --with-extra-charsets=complex --enable-thread-safe-client --with-unix-socket-path=/tmp/mysql-4.1.22.sock --without-extra-tools --disable-dependency-tracking --prefix=/tmp/mysql-4.1.22 --with-ndbcluster

How to repeat:
[o2k]:/tmp/mysql-4.1.22 $ bin/perror   
bin/perror Ver 2.10, for sgi-irix6.5 (mips)
[..]

[o2k]:/tmp/mysql-4.1.22 $ bin/perror 12
Segmentation fault (core dumped)

[o2k]:/tmp/mysql-4.1.22 $ file core
core: IRIX N32 core dump of 'perror'
[o2k]:/tmp/mysql-4.1.22 $ dbx bin/perror core
dbx version 7.3.7 (96228_Jun17 patchSG0005844) Jun 17 2005 02:44:36
Debugger Server version Jun 17 2005 02:47:22
Core from signal SIGSEGV: Segmentation violation
(dbx) where

Thread 0x10000
>  0 strlen(0x0, 0x0, 0x0, 0x1, 0xfb4bc78, 0x8, 0x1000bb40, 0x7ffe4c60) ["/xlv41/6.5.30m/work/irix/lib/libc/libc_n32_M4/strings/strlen.s":58, 0xfa43040]
   1 main(0x1, 0x7ffe4658, 0x0, 0x1, 0x69, 0x6e, 0x2, 0x69) ["/raids/strip2/MIPS/mysql-4.1.22/extra/perror.c":227, 0x1000a2b0]
   2 __start() ["/xlv55/kudzu-apr12/work/irix/lib/libc/libc_n32_M4/csu/crt1text.s":177, 0x10009b68]
(dbx) quit

And the same with gdb
[o2k]:/tmp/mysql-4.1.22 $ gdb bin/perror core
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "mips-sgi-irix6.5"...
Core was generated by `perror'.
Program terminated with signal 11, Segmentation fault.

warning: wrong size gregset struct in core file
Reading symbols from /usr/lib32/libpthread.so...done.
Loaded symbols for /usr/lib32/libpthread.so
Reading symbols from /usr/lib32/libgen.so...done.
Loaded symbols for /usr/lib32/libgen.so
Reading symbols from /usr/lib32/libnsl.so...done.
Loaded symbols for /usr/lib32/libnsl.so
Reading symbols from /usr/lib32/libm.so...done.
Loaded symbols for /usr/lib32/libm.so
Reading symbols from /usr/lib32/libc.so.1...done.
Loaded symbols for /usr/lib32/libc.so.1

warning: wrong size gregset struct in core file
#0  0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x00000000 in ?? ()
Previous frame identical to this frame (corrupt stack?)
(gdb)

regards
Joerg Behrens
[11 Jan 2007 13:44] Sveta Smirnova
Thank you for the report.

Verified as described on IRIX
[11 Jan 2007 13:45] Sveta Smirnova
It can be duplicate of Bug #20145
[11 Jan 2007 14:07] Joerg Behrens
Looks very similar! 
Can you verify if the 5.0.27 contains the patch? Because as reportet this version works fine for me at this point.

Keep in mind that this error is reportet also for some 4.1.x versions ;)

regards
Joerg
[11 Jan 2007 14:19] Sveta Smirnova
Yes, 5.0 branch contains the patch.
[6 Feb 2007 22:00] 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/19451

ChangeSet@1.2603, 2007-02-06 23:00:18+01:00, msvensson@neptunus.(none) +1 -0
  Bug#25344  Segmentation violation when try to run the perror utility
   - strerror might return NULL on some platforms
[14 Feb 2007 14:59] Chad MILLER
Available in 4.1.23, 5.0.36, and 5.1.16-beta.
[15 Feb 2007 4:41] Paul Dubois
Noted in 4.1.23, 5.0.36, 5.1.16 changelogs.

perror crashed on some platforms due to failure to handle a NULL
pointer.