Bug #98790 C API Asynchronous Function segmentation fault
Submitted: 1 Mar 2020 11:42 Modified: 2 Mar 2020 7:38
Reporter: Niklaus Schen Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:8.0 OS:CentOS (7)
Assigned to: CPU Architecture:Any

[1 Mar 2020 11:42] Niklaus Schen
Description:
This function will encounter a segmentation fault:

enum net_async_status mysql_real_connect_nonblocking(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag)

with these arguments:
mysql -> whatever
host -> 12.0.0.1               not 127.0.0.1, but 12.0.0.1
user -> whatever
passwd -> whatever
db -> whatever
port -> 3306
unix_socket -> NULL
client_flag -> 0

The valgrind will print out:
Invalid write of size 1
   at 0x5086769: cli_safe_read_with_ok_nonblocking(MYSQL*, bool, bool*, unsigned long*) (client.cc:1108)
   by 0x5086B05: csm_read_greeting(mysql_async_connect*) (client.cc:6200)
   by 0x508DE10: mysql_real_connect_nonblocking (client.cc:5724)
   ... // my own functions

How to repeat:
just call mysql_real_connect_nonblocking with the arguments that given above.
[1 Mar 2020 11:49] Niklaus Schen
I also tried some other IPs and ports.
The conclusion is, if IP or port cannot help to build up a TCP connection, then this segmentation fault happened.
[2 Mar 2020 7:38] MySQL Verification Team
Hello Niklaus Schen,

Thank you for the report and feedback.
Imho this is duplicate of Bug #97805, please see Bug #97805.

regards,
Umesh
[2 Mar 2020 7:44] MySQL Verification Team
Related - Bug #98254 	mysql_real_connect_nonblocking() is not nonblocking
          Bug #98574 	mysql_real_connect_nonblocking() blocks

[14 Feb 15:21] Paul Dubois

Posted by developer:
 
Fixed in 8.0.20.

The mysql_real_connect_nonblocking() C API function exhibited
blocking behavior.