Bug #90252 init_server_components() passes wrong number of arguments to LogErr()
Submitted: 29 Mar 2018 7:22 Modified: 5 Apr 2018 12:50
Reporter: Alexey Kopytov Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:8.0.4 OS:Any
Assigned to: CPU Architecture:Any

[29 Mar 2018 7:22] Alexey Kopytov
Description:
The following code in mysqld.cc:init_server_components() passes
invalid number of arguments to LogErr() when forming an error message:

---
    LogErr(ERROR_LEVEL, ER_RPL_CANT_HAVE_SAME_BASENAME,
           log_bin_basename, "--log-bin",
           default_binlogfile_name_from_hostname,
           "--relay-log", default_relaylogfile_name);
--

If we look at the error text for ER_RPL_CANT_HAVE_SAME_BASENAME in
errmsg-utf8.txt, we'll see:

  eng "Cannot have same base name '%s' for both binary and relay logs. Please check %s (default '%s' if --log-bin option is not used, default '%s' if --log-bin option is used without argument) and %s (default '%s') options to ensure they do not conflict."

So it expects 6 strings passed as parameters. While the above code in
init_server_components() passes only 5.

That code is covered by the binlog.binlog_same_basename_relaylog MTR
test, and it actually fails on my machine with a segmentation fault
precisely for that reason.

How to repeat:
Apparently binlog_same_basename_relaylog passes MTR tests and sanitizers on
most machines. So code inspection is probably the best way to "repeat".

Suggested fix:
I suspect the intention was to also pass default_binlogfile_name as the 5th 
argument to LogErr() right before default_binlogfile_name_from_hostname.
[29 Mar 2018 7:42] Alexey Kopytov
Another suggestion: make LogErr() use an inline function with GCC
__attribute__ ((format)), so things like this could be caught by 
the compiler.
[30 Mar 2018 7:16] Umesh Shastry
Hello Alexey,

Thank you for the report and feedback!

Thanks,
Umesh
[31 Mar 2018 6:42] Alexey Kopytov
Just realized compiler checks will not help here, so disregard my last
comment.
[5 Apr 2018 12:50] Maria Couceiro
Posted by developer:
 
This issue was fixed by a post-push fix for WL#9344.
[9 Apr 2018 6:17] Umesh Shastry
Bug #90344 marked as duplicate of this one