Commit dd6356ac authored by Bjorn Munch's avatar Bjorn Munch

Bug #43074 MTR2 is not accessing core dumps when a path is too long

Executable path is truncated in core
If we see truncated path, try to guess using strings and grep
If that doesn't work either, use known mysqld path
parent 776bb04a
...@@ -22,6 +22,33 @@ use My::Platform; ...@@ -22,6 +22,33 @@ use My::Platform;
use File::Temp qw/ tempfile tempdir /; use File::Temp qw/ tempfile tempdir /;
my $hint_mysqld; # Last resort guess for executable path
# If path in core file is 79 chars we assume it's been truncated
# Looks like we can still find the full path using 'strings'
# If that doesn't work, use the hint (mysqld path) as last resort.
sub _verify_binpath {
my ($binary, $core_name)= @_;
my $binpath;
if (length $binary != 79) {
$binpath= $binary;
print "Core generated by '$binpath'\n";
} else {
# Last occurrence of path ending in /mysql*, cut from first /
if (`strings '$core_name' | grep "/mysql[^/. ]*\$" | tail -1` =~ /(\/.*)/) {
$binpath= $1;
print "Guessing that core was generated by '$binpath'\n";
} else {
return unless $hint_mysqld;
$binpath= $hint_mysqld;
print "Wild guess that core was generated by '$binpath'\n";
}
}
return $binpath;
}
sub _gdb { sub _gdb {
my ($core_name)= @_; my ($core_name)= @_;
...@@ -33,7 +60,8 @@ sub _gdb { ...@@ -33,7 +60,8 @@ sub _gdb {
`gdb -c '$core_name' --batch 2>&1` =~ `gdb -c '$core_name' --batch 2>&1` =~
/Core was generated by `([^\s\'\`]+)/; /Core was generated by `([^\s\'\`]+)/;
my $binary= $1 or return; my $binary= $1 or return;
print "Core generated by '$binary'\n";
$binary= _verify_binpath ($binary, $core_name) or return;
# Create tempfile containing gdb commands # Create tempfile containing gdb commands
my ($tmp, $tmp_name) = tempfile(); my ($tmp, $tmp_name) = tempfile();
...@@ -73,7 +101,8 @@ sub _dbx { ...@@ -73,7 +101,8 @@ sub _dbx {
`echo | dbx - '$core_name' 2>&1` =~ `echo | dbx - '$core_name' 2>&1` =~
/Corefile specified executable: "([^"]+)"/; /Corefile specified executable: "([^"]+)"/;
my $binary= $1 or return; my $binary= $1 or return;
print "Core generated by '$binary'\n";
$binary= _verify_binpath ($binary, $core_name) or return;
# Find all threads # Find all threads
my @thr_ids = `echo threads | dbx '$binary' '$core_name' 2>&1` =~ /t@\d+/g; my @thr_ids = `echo threads | dbx '$binary' '$core_name' 2>&1` =~ /t@\d+/g;
...@@ -225,7 +254,8 @@ EOF ...@@ -225,7 +254,8 @@ EOF
sub show { sub show {
my ($class, $core_name)= @_; my ($class, $core_name, $exe_mysqld)= @_;
$hint_mysqld= $exe_mysqld;
# On Windows, rely on cdb to be there... # On Windows, rely on cdb to be there...
if (IS_WINDOWS) if (IS_WINDOWS)
......
...@@ -429,6 +429,7 @@ sub run_test_server ($$$) { ...@@ -429,6 +429,7 @@ sub run_test_server ($$$) {
my $completed= []; my $completed= [];
my %running; my %running;
my $result; my $result;
my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump
my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout()); my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout());
...@@ -500,7 +501,7 @@ sub run_test_server ($$$) { ...@@ -500,7 +501,7 @@ sub run_test_server ($$$) {
mtr_report(" - found '$core_name'", mtr_report(" - found '$core_name'",
"($num_saved_cores/$opt_max_save_core)"); "($num_saved_cores/$opt_max_save_core)");
My::CoreDump->show($core_file); My::CoreDump->show($core_file, $exe_mysqld);
if ($num_saved_cores >= $opt_max_save_core) { if ($num_saved_cores >= $opt_max_save_core) {
mtr_report(" - deleting it, already saved", mtr_report(" - deleting it, already saved",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment