php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10565 mysql_real_connect dumps core, fix included
Submitted: 2001-04-30 16:57 UTC Modified: 2001-06-02 22:28 UTC
From: glen at ldscn dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.0.4pl1 OS: SCO OpenServer 5.0.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: glen at ldscn dot com
New email:
PHP Version: OS:

 

 [2001-04-30 16:57 UTC] glen at ldscn dot com
** This is a problem in MySql.  This report provides a code
modification to compensate for the MySql problem. **

Under SCO OpenServer 5.0.6, Apache 1.3.19, PHP 4.0.4 PL 1,
and MySql 3.23.36 (precompiled MySQL for OpenServer 5.0.x),
calls to mysql_real_connect will silently dump core if
mysql_init was not allowed to *allocate* the memory for the
MySQL structure.

To function properly, mysql_init must be passed NULL, thus
allowing it to allocate and manage the memory.  If you use
a previously malloc()'ed or static structure, MySQL will 
dump core on connect.

We find this problem to be present in MySQL, and can 
duplicate it using a C code stub.  The problem, of course,
also exists in PHP, causing a core dump there as well,
since PHP pre-malloc()'s its own structure.

Here is a DIFF for ext/mysql/php_mysql.c which fixes the
problem for us.  It's ugly, and hack-y, but it works.  FYI.

198c198
<       efree(link);
---
>       /* efree(link); */
456c456
<               mysql = (MYSQL *) malloc(sizeof(MYSQL));
---
>               /* mysql = (MYSQL *) malloc(sizeof(MYSQL)); */
458c458
<               mysql_init(mysql);
---
>               mysql = mysql_init(NULL);
542c542
<               mysql = (MYSQL *) emalloc(sizeof(MYSQL));
---
>               /* mysql = (MYSQL *) emalloc(sizeof(MYSQL)); */
544c544
<               mysql_init(mysql);
---
>               mysql = mysql_init(NULL);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-02 06:59 UTC] cynic@php.net
mailed MySQL
 [2001-05-02 10:46 UTC] cynic@php.net
I had a conversation with Sinisa, this is the outcome. If it isn't true, please contact the MySQL team directly. All in all, you said it's a bug in MySQL.


From: Sinisa Milivojevic <sinisa@mysql.com>
To: cynic@xxx.yyy
Cc: win32@lists.mysql.com
Subject: Re: mysql_real_connect dumps core

Cynic writes:
> no, the patch was (probably) generated with diff -c. read:
> 
> -              mysql_init(mysql);
> ---
> +              mysql = mysql_init(NULL);
> 

MYSQL *mysql = (MYSQL *)NULL;

mysql = mysql_init(mysql);
mysql_real_connect(mysql,...

must work on any system with 3.23 client API.


Regards,

Sinisa

      ____  __     _____   _____  ___     ==  MySQL AB
     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|     Sinisa Milivojevic
    /*/ /*/ /*/   \*\_   |*|   |*||*|     mailto:sinisa@mysql.com
   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|     Larnaca, Cyprus
  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|____
  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^
             /*/             \*\                Developers Team 


 [2001-06-02 22:28 UTC] sniper@php.net
This is not the correct place to report bugs in MySQL itself.


 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Feb 05 02:05:48 2023 UTC