Bug #56669 mysql_ping generates 'segmentation fault' libmysqlclient_r
| Submitted: | 9 Sep 2010 1:20 | Modified: | 10 Sep 2010 1:30 |
|---|---|---|---|
| Reporter: | Gabriel LePage | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: C API (client library) | Severity: | S3 (Non-critical) |
| Version: | 5.1.41 | OS: | Linux |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | mysql_ping mysql c api segmenation fault libmysqlclient_r | ||
[9 Sep 2010 1:20]
Gabriel LePage
[10 Sep 2010 1:30]
Alexey Kishkin
Confirm
$ cat tst56669.c
#include <my_global.h>
#include <mysql.h>
int main(int argc, char **argv)
{
MYSQL *conn;
conn = mysql_init(NULL);
mysql_ping(conn);
mysql_close(conn);
}
$ ./tst56669
Segmentation fault
[10 Nov 2011 16:53]
plop plop
Same here with libmysqlclient16 5.1.58. MYSQL db; mysql_library_init(0, NULL, NULL) mysql_init(&db); mysql_ping(&db); >> segfault ==5911== Invalid read of size 8 ==5911== at 0x532F09A: mysql_ping (in /usr/lib/libmysqlclient.so.16.0.0) ==5911== Address 0x8 is not stack'd, malloc'd or (recently) free'd ==5911== ==5911== ==5911== Process terminating with default action of signal 11 (SIGSEGV) ==5911== Access not within mapped region at address 0x8 ==5911== at 0x532F09A: mysql_ping (in /usr/lib/libmysqlclient.so.16.0.0)
[10 Nov 2011 22:57]
plop plop
I have to mention that I use MYSQL_OPT_RECONNECT true. So I guess the segfault might happen while trying to reconnect ? I have not tried the crash test with MYSQL_OPT_RECONNECT false though but if the segfault happen to be caused by the reconnect attempt, I still believe that it should be up to the mysql API to deal with the possibility that mysql_real_connect() could very well not have been called yet.
[10 Nov 2011 23:27]
plop plop
So I just checked, the segfault has nothing to do with MYSQL_OPT_RECONNECT, should it be true or false.
[7 Dec 2011 21:13]
Stan Sieler
Doing: mysql_ping (NULL) generates a "Bus Error" (segmentation fault on some platforms).
Reproduced on Linux and Mac OS X.
Suggested fix, near start of mysql_ping code:
if conn == NULL)
return CR_CONN_IS_NULL (a new error code, becuase CR_NULL_POINTER really isn't good enough here :)
Yes, the workaround is "don't do that" ... but it should still be fixed.
[26 Mar 2019 1:41]
Michael Robinton
mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) ping failed: Calling a synchronous function on an asynchronous handle Ubuntu 16.04.4 mysql_read_timeout set, async read operation polling mysql_async_ready flag next program step after failure is a ping to re-establish the connection using the same $dbh mysql handler executed "DIE", should warn and return with error (ping failure)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.059 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.