mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
bzr merge from guilhem's maria tree to our local 5.1
configure.in: Manually merged mysql-test/lib/My/ConfigFactory.pm: Manually merged mysql-test/mysql-test-run.pl: Manually merged mysql-test/t/information_schema.test: Manually merged sql/handler.cc: Manually merged support-files/mysql.spec.sh: Manually merged
This commit is contained in:
@ -116,8 +116,8 @@ sub fix_tmpdir {
|
||||
|
||||
sub fix_log_error {
|
||||
my ($self, $config, $group_name, $group)= @_;
|
||||
my $dir= dirname($group->value('datadir'));
|
||||
return "$dir/mysqld.err";
|
||||
my $dir= $self->{ARGS}->{vardir};
|
||||
return "$dir/log/$group_name.err";
|
||||
}
|
||||
|
||||
sub fix_log {
|
||||
@ -204,7 +204,7 @@ my @mysqld_rules=
|
||||
{ 'port' => \&fix_port },
|
||||
{ '#extra-port' => \&fix_port },
|
||||
{ 'socket' => \&fix_socket },
|
||||
{ 'log-error' => \&fix_log_error },
|
||||
{ '#log-error' => \&fix_log_error },
|
||||
{ 'general-log' => sub { return 1; } },
|
||||
{ 'general-log-file' => \&fix_log },
|
||||
{ 'slow-query-log-file' => \&fix_log_slow_queries },
|
||||
@ -392,7 +392,7 @@ sub post_check_embedded_group {
|
||||
|
||||
my @no_copy =
|
||||
(
|
||||
'log-error', # Embedded server writes stderr to mysqltest's log file
|
||||
'#log-error', # Embedded server writes stderr to mysqltest's log file
|
||||
'slave-net-timeout', # Embedded server are not build with replication
|
||||
);
|
||||
|
||||
|
@ -104,9 +104,136 @@ EOF
|
||||
}
|
||||
|
||||
|
||||
# Check that Debugging tools for Windows are installed
|
||||
sub cdb_check {
|
||||
`cdb -? 2>&1`;
|
||||
if ($? >> 8)
|
||||
{
|
||||
print "Cannot find cdb. Please Install Debugging tools for Windows\n";
|
||||
print "from http://www.microsoft.com/whdc/devtools/debugging/";
|
||||
if($ENV{'ProgramW6432'})
|
||||
{
|
||||
print "install64bit.mspx (native x64 version)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "installx86.mspx\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub _cdb {
|
||||
my ($core_name)= @_;
|
||||
print "\nTrying 'cdb' to get a backtrace\n";
|
||||
return unless -f $core_name;
|
||||
|
||||
# Try to set environment for debugging tools for Windows
|
||||
if ($ENV{'PATH'} !~ /Debugging Tools/)
|
||||
{
|
||||
if ($ENV{'ProgramW6432'})
|
||||
{
|
||||
# On x64 computer
|
||||
$ENV{'PATH'}.= ";".$ENV{'ProgramW6432'}."\\Debugging Tools For Windows (x64)";
|
||||
}
|
||||
else
|
||||
{
|
||||
# On x86 computer. Newest versions of Debugging tools are installed in the
|
||||
# directory with (x86) suffix, older versions did not have this suffix.
|
||||
$ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows (x86)";
|
||||
$ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Read module list, find out the name of executable and
|
||||
# build symbol path (required by cdb if executable was built on
|
||||
# different machine)
|
||||
my $tmp_name= $core_name.".cdb_lmv";
|
||||
`cdb -z $core_name -c \"lmv;q\" > $tmp_name 2>&1`;
|
||||
if ($? >> 8)
|
||||
{
|
||||
unlink($tmp_name);
|
||||
# check if cdb is installed and complain if not
|
||||
cdb_check();
|
||||
return;
|
||||
}
|
||||
|
||||
open(temp,"< $tmp_name");
|
||||
my %dirhash=();
|
||||
while(<temp>)
|
||||
{
|
||||
if($_ =~ /Image path\: (.*)/)
|
||||
{
|
||||
if (rindex($1,'\\') != -1)
|
||||
{
|
||||
my $dir= substr($1, 0, rindex($1,'\\'));
|
||||
$dirhash{$dir}++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(temp);
|
||||
unlink($tmp_name);
|
||||
|
||||
my $image_path= join(";", (keys %dirhash),".");
|
||||
|
||||
# For better callstacks, setup _NT_SYMBOL_PATH to include
|
||||
# OS symbols. Note : Dowloading symbols for the first time
|
||||
# can take some minutes
|
||||
if (!$ENV{'_NT_SYMBOL_PATH'})
|
||||
{
|
||||
my $windir= $ENV{'windir'};
|
||||
my $symbol_cache= substr($windir ,0, index($windir,'\\'))."\\cdb_symbols";
|
||||
|
||||
print "OS debug symbols will be downloaded and stored in $symbol_cache.\n";
|
||||
print "You can control the location of symbol cache with _NT_SYMBOL_PATH\n";
|
||||
print "environment variable. Please refer to Microsoft KB article\n";
|
||||
print "http://support.microsoft.com/kb/311503 for details about _NT_SYMBOL_PATH\n";
|
||||
print "-------------------------------------------------------------------------\n";
|
||||
|
||||
$ENV{'_NT_SYMBOL_PATH'}.=
|
||||
"srv*".$symbol_cache."*http://msdl.microsoft.com/download/symbols";
|
||||
}
|
||||
|
||||
my $symbol_path= $image_path.";".$ENV{'_NT_SYMBOL_PATH'};
|
||||
|
||||
|
||||
# Run cdb. Use "analyze" extension to print crashing thread stacktrace
|
||||
# and "uniqstack" to print other threads
|
||||
|
||||
my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q";
|
||||
my $cdb_output=
|
||||
`cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`;
|
||||
return if $? >> 8;
|
||||
return unless $cdb_output;
|
||||
|
||||
# Remove comments (lines starting with *), stack pointer and frame
|
||||
# pointer adresses and offsets to function to make output better readable
|
||||
$cdb_output=~ s/^\*.*\n//gm;
|
||||
$cdb_output=~ s/^([\:0-9a-fA-F\`]+ )+//gm;
|
||||
$cdb_output=~ s/^ChildEBP RetAddr//gm;
|
||||
$cdb_output=~ s/^Child\-SP RetAddr Call Site//gm;
|
||||
$cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm;
|
||||
|
||||
print <<EOF, $cdb_output, "\n";
|
||||
Output from cdb follows. Faulting thread is printed twice,with and without function parameters
|
||||
Search for STACK_TEXT to see the stack trace of
|
||||
the faulting thread. Callstacks of other threads are printed after it.
|
||||
EOF
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sub show {
|
||||
my ($class, $core_name)= @_;
|
||||
|
||||
# On Windows, rely on cdb to be there...
|
||||
if (IS_WINDOWS)
|
||||
{
|
||||
_cdb($core_name);
|
||||
return;
|
||||
}
|
||||
|
||||
# We try dbx first; gdb itself may coredump if run on a Sun Studio
|
||||
# compiled binary on Solaris.
|
||||
|
||||
|
@ -113,8 +113,8 @@ sub check_socket_path_length {
|
||||
|
||||
# Create a tempfile name with same length as "path"
|
||||
my $tmpdir = tempdir( CLEANUP => 0);
|
||||
my $len = length($path) - length($tmpdir);
|
||||
my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1);
|
||||
my $len = length($path) - length($tmpdir) - 1;
|
||||
my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1);
|
||||
my $sock;
|
||||
eval {
|
||||
$sock= new IO::Socket::UNIX
|
||||
@ -126,17 +126,15 @@ sub check_socket_path_length {
|
||||
die "Could not create UNIX domain socket: $!"
|
||||
unless defined $sock;
|
||||
|
||||
die "UNIX domain socket patch was truncated"
|
||||
die "UNIX domain socket path was truncated"
|
||||
unless ($testfile eq $sock->hostpath());
|
||||
|
||||
$truncated= 0; # Yes, it worked!
|
||||
|
||||
};
|
||||
#print "check_socket_path_length, failed: ", $@, '\n' if ($@);
|
||||
|
||||
$sock= undef; # Close socket
|
||||
unlink($testfile); # Remove the physical file
|
||||
rmdir($tmpdir); # Remove the tempdir
|
||||
rmtree($tmpdir); # Remove the tempdir and any socket file created
|
||||
return $truncated;
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,7 @@ sub new {
|
||||
my $output = delete($opts{'output'});
|
||||
my $error = delete($opts{'error'});
|
||||
my $verbose = delete($opts{'verbose'});
|
||||
my $nocore = delete($opts{'nocore'});
|
||||
my $host = delete($opts{'host'});
|
||||
my $shutdown = delete($opts{'shutdown'});
|
||||
my $user_data= delete($opts{'user_data'});
|
||||
@ -137,6 +138,7 @@ sub new {
|
||||
push(@safe_args, $safe_script) if defined $safe_script;
|
||||
|
||||
push(@safe_args, "--verbose") if $verbose > 0;
|
||||
push(@safe_args, "--nocore") if $nocore;
|
||||
|
||||
# Point the safe_process at the right parent if running on cygwin
|
||||
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -149,7 +150,8 @@ int main(int argc, char* const argv[] )
|
||||
char* const* child_argv= 0;
|
||||
pid_t own_pid= getpid();
|
||||
pid_t parent_pid= getppid();
|
||||
|
||||
bool nocore = false;
|
||||
|
||||
/* Install signal handlers */
|
||||
signal(SIGTERM, handle_signal);
|
||||
signal(SIGINT, handle_signal);
|
||||
@ -181,6 +183,9 @@ int main(int argc, char* const argv[] )
|
||||
start++; /* Step past = */
|
||||
if ((parent_pid= atoi(start)) == 0)
|
||||
die("Invalid value '%s' passed to --parent-id", start);
|
||||
} else if ( strcmp(arg, "--nocore") == 0 )
|
||||
{
|
||||
nocore = true; // Don't allow the process to dump core
|
||||
}
|
||||
else
|
||||
die("Unknown option: %s", arg);
|
||||
@ -218,6 +223,15 @@ int main(int argc, char* const argv[] )
|
||||
// it and any childs(that hasn't changed group themself)
|
||||
setpgid(0, 0);
|
||||
|
||||
if (nocore)
|
||||
{
|
||||
struct rlimit corelim = { 0, 0 };
|
||||
if (setrlimit (RLIMIT_CORE, &corelim) < 0)
|
||||
{
|
||||
message("setrlimit failed, errno=%d", errno);
|
||||
}
|
||||
}
|
||||
|
||||
// Signal that child is ready
|
||||
buf= 37;
|
||||
write(pfd[1], &buf, 1);
|
||||
|
@ -77,14 +77,29 @@ static void message(const char* fmt, ...)
|
||||
|
||||
static void die(const char* fmt, ...)
|
||||
{
|
||||
DWORD last_err= GetLastError();
|
||||
va_list args;
|
||||
fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name);
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
if (int last_err= GetLastError())
|
||||
fprintf(stderr, "error: %d, %s\n", last_err, strerror(last_err));
|
||||
if (last_err)
|
||||
{
|
||||
char *message_text;
|
||||
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_err , 0, (LPSTR)&message_text,
|
||||
0, NULL))
|
||||
{
|
||||
fprintf(stderr,"error: %d, %s\n",last_err, message_text);
|
||||
LocalFree(message_text);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FormatMessage failed, print error code only */
|
||||
fprintf(stderr,"error:%d\n", last_err);
|
||||
}
|
||||
}
|
||||
fflush(stderr);
|
||||
exit(1);
|
||||
}
|
||||
@ -237,12 +252,19 @@ int main(int argc, const char** argv )
|
||||
/*
|
||||
Create the process suspended to make sure it's assigned to the
|
||||
Job before it creates any process of it's own
|
||||
|
||||
Allow the new process to break away from any job that this
|
||||
process is part of so that it can be assigned to the new JobObject
|
||||
we just created. This is safe since the new JobObject is created with
|
||||
the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag, making sure it will be
|
||||
terminated when the last handle to it is closed(which is owned by
|
||||
this process).
|
||||
*/
|
||||
if (CreateProcess(NULL, (LPSTR)child_args,
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE, /* inherit handles */
|
||||
CREATE_SUSPENDED,
|
||||
CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB,
|
||||
NULL,
|
||||
NULL,
|
||||
&si,
|
||||
|
Reference in New Issue
Block a user