Valgrind Invalid File Descriptor In Syscall Close

Closed

Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. WL#11625: MTR: Review the VALGRIND warning patterns in mtrwarnings.sql file Affects: Server-8.0 — Status: Complete.

Valgrind

This shows up as a Valgrind warning

18197 Warning: invalid file descriptor -1 in syscall close()
18197 at 0x5F6E5BD: ??? (syscall-template.S:84)
18197 by 0xF95F34: inline_mysql_socket_close (mysql_socket.h:1090)
18197 by 0xF96AF3: vio_shutdown (viosocket.c:490)
18197 by 0x7C6BE0: THD::disconnect() (sql_class.cc:2057)
18197 by 0x637486: close_connection(THD*, unsigned int) (mysqld.cc:2886)
18197 by 0x7D63E3: do_handle_one_connection(THD*) (sql_connect.cc:1547)
18197 by 0x7D5E57: handle_one_connection (sql_connect.cc:1444)
18197 by 0xB98416: pfs_spawn_thread (pfs.cc:1860)
18197 by 0x5F656F9: start_thread (pthread_create.c:333)
18197 by 0x6B22B5C: clone (clone.S:109)

InvalidSyscall

Valgrind Invalid File Descriptor In Syscall Close Command

on e.g.

rpl.rpl_semi_sync_shutdown_hang 'mix' [ fail ] Found warnings/errors in server log file!
rpl.rpl_gtid_mts_relay_log_recovery_auto_pos_on_off 'mix' w3 [ fail ] Found warnings/errors in server log file!
rpl.rpl_report_port 'mix' w1 [ fail ] Found warnings/errors in server log file!
rpl.rpl_recovery_replicate_same_server_id 'mix' w4 [ fail ] Found warnings/errors in server log file!
rpl.rpl_change_master_crash_safe 'mix' w2 [ fail ] Found warnings/errors in server log file!
rpl.rpl_change_master 'mix' w1 [ fail ] Found warnings/errors in server log file!
rpl.rpl_alter_repository 'mix' w3 [ fail ] Found warnings/errors in server log file!
rpl.rpl_gtid_deployment_step 'mix' w1 [ fail ] Found warnings/errors in server log file!
rpl.rpl_recovery_replicate_same_server_id 'row' w4 [ fail ] Found warnings/errors in server log file!
main.mysql_client_test w4 [ fail ] Found warnings/errors in server log file!
auth_sec.mysql_native_plugin w3 [ fail ] Found warnings/errors in server log file!

Valgrind Invalid File Descriptor In Syscall Closed

The reason is that THD::disconnect is getting called twice, once from server thread-killing thread:
kill_server_threads -> kill_server -> close_connections -> close_connection -> THD::disconnect;
and the second time from the query thread itself, as in the above stacktrace.