Bug #20731 perror core dump
Submitted: 27 Jun 2006 20:28 Modified: 29 Jun 2006 10:42
Reporter: Steven Xie Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.19 OS:sprac solaris 2.8 32 bits
Assigned to: Assigned Account CPU Architecture:Any

[27 Jun 2006 20:28] Steven Xie
Description:
auto-config doesn't setup HAVE_SYS_ERRLIST.
so perror core dumps at
 unknown_error= malloc(strlen(msg)+1);

Plus, I think it's not safe to have code like below 

 /*
      On some system, like NETWARE, strerror(unknown_error) returns a
      string 'Unknown Error'.  To avoid printing it we try to find the
      error string by asking for an impossible big error message.
    */
    msg= strerror(10000);  
   /* msg could be set to NULL under some platforms
    * then strlen would core .
    */

                                                                                                                                                             
    /*
      Allocate a buffer for unknown_error since strerror always returns
      the same pointer on some platforms such as Windows
    */
    unknown_error= malloc(strlen(msg)+1);

How to repeat:
use default config build under solaris 2.8

Suggested fix:
/*
      On some system, like NETWARE, strerror(unknown_error) returns a
      string 'Unknown Error'.  To avoid printing it we try to find the
      error string by asking for an impossible big error message.
    */
    msg= strerror(10000);  
   /* msg could be set to NULL on some platforms
    *  e.g solaris 2.8
    */
     if (NULL==msg)
         msg="Unknown  Error";

                                                                                                                                                             
    /*
      Allocate a buffer for unknown_error since strerror always returns
      the same pointer on some platforms such as Windows
    */
    unknown_error= malloc(strlen(msg)+1);
[29 Jun 2006 10:42] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

There is only architecture difference with bug #20145. This bug is not reproducible on Solaris 9 and Solaris 10.