Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Bjarne Kvinge <rolf@xamarin.com>2011-12-20 03:56:40 +0400
committerDuncan Mak <duncan.mak@xamarin.com>2012-01-31 00:10:02 +0400
commit9435de91f2e243db9b857ad09a57aba9cfc99038 (patch)
tree2f35d7f54cd81dfcf3951f8f760f3a00b890847e
parent12818535537076f9bc55022dfe7f5af7b6acb4c9 (diff)
Fix gdb backtraces on OSX.2.10.9
We can't redirect output from gdb: since gdb will suspend us we won't be able to read from the pipe we've redirected output to, and we'll end up deadlocking if gdb outputs a lot of data (see bug #2548).
-rw-r--r--mono/mini/mini-darwin.c7
-rw-r--r--mono/mini/mini-exceptions.c29
-rw-r--r--mono/mini/mini-posix.c6
-rw-r--r--mono/mini/mini.h2
4 files changed, 8 insertions, 36 deletions
diff --git a/mono/mini/mini-darwin.c b/mono/mini/mini-darwin.c
index bfd9f28f574..530b882e013 100644
--- a/mono/mini/mini-darwin.c
+++ b/mono/mini/mini-darwin.c
@@ -226,16 +226,15 @@ mono_runtime_syscall_fork ()
return (pid_t) fork ();
}
-gboolean
+void
mono_gdb_render_native_backtraces (pid_t crashed_pid)
{
- return FALSE; // disable for now due to #2548.
const char *argv [5];
char gdb_template [] = "/tmp/mono-gdb-commands.XXXXXX";
argv [0] = g_find_program_in_path ("gdb");
if (argv [0] == NULL) {
- return FALSE;
+ return;
}
if (mkstemp (gdb_template) != -1) {
@@ -257,6 +256,4 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
unlink (gdb_template);
}
-
- return TRUE;
}
diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c
index fc74b08c021..0567a24a7b8 100644
--- a/mono/mini/mini-exceptions.c
+++ b/mono/mini/mini-exceptions.c
@@ -2170,16 +2170,10 @@ mono_handle_native_sigsegv (int signal, void *ctx)
#if !defined(HOST_WIN32) && defined(HAVE_SYS_SYSCALL_H) && defined(SYS_fork)
if (!mini_get_debug_options ()->no_gdb_backtrace && !mono_debug_using_mono_debugger ()) {
/* From g_spawn_command_line_sync () in eglib */
- int res;
- int stdout_pipe [2] = { -1, -1 };
pid_t pid;
int status;
- char buffer [1024];
pid_t crashed_pid = getpid ();
- res = pipe (stdout_pipe);
- g_assert (res != -1);
-
//pid = fork ();
/*
* glibc fork acquires some locks, so if the crash happened inside malloc/free,
@@ -2188,31 +2182,14 @@ mono_handle_native_sigsegv (int signal, void *ctx)
pid = mono_runtime_syscall_fork ();
if (pid == 0) {
- close (stdout_pipe [0]);
- dup2 (stdout_pipe [1], STDOUT_FILENO);
-
- for (i = getdtablesize () - 1; i >= 3; i--)
- close (i);
-
- if (!mono_gdb_render_native_backtraces (crashed_pid))
- close (STDOUT_FILENO);
+ dup2 (STDERR_FILENO, STDOUT_FILENO);
+ mono_gdb_render_native_backtraces (crashed_pid);
exit (1);
}
- close (stdout_pipe [1]);
-
fprintf (stderr, "\nDebug info from gdb:\n\n");
-
- while (1) {
- int nread = read (stdout_pipe [0], buffer, 1024);
-
- if (nread <= 0)
- break;
- write (STDERR_FILENO, buffer, nread);
- }
-
- waitpid (pid, &status, WNOHANG);
+ waitpid (pid, &status, 0);
}
#endif
/*
diff --git a/mono/mini/mini-posix.c b/mono/mini/mini-posix.c
index d336e35ffa1..f58606ddb86 100644
--- a/mono/mini/mini-posix.c
+++ b/mono/mini/mini-posix.c
@@ -635,7 +635,7 @@ mono_runtime_syscall_fork ()
#endif
}
-gboolean
+void
mono_gdb_render_native_backtraces (pid_t crashed_pid)
{
const char *argv [9];
@@ -643,7 +643,7 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
argv [0] = g_find_program_in_path ("gdb");
if (argv [0] == NULL) {
- return FALSE;
+ return;
}
argv [1] = "-ex";
@@ -657,8 +657,6 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid)
argv [8] = 0;
execv (argv [0], (char**)argv);
-
- return TRUE;
}
#endif
#endif /* __native_client__ */
diff --git a/mono/mini/mini.h b/mono/mini/mini.h
index 38a9e46c3c3..44749e26b99 100644
--- a/mono/mini/mini.h
+++ b/mono/mini/mini.h
@@ -2400,7 +2400,7 @@ void mono_runtime_setup_stat_profiler (void) MONO_INTERNAL;
void mono_runtime_shutdown_stat_profiler (void) MONO_INTERNAL;
void mono_runtime_posix_install_handlers (void) MONO_INTERNAL;
pid_t mono_runtime_syscall_fork (void) MONO_INTERNAL;
-gboolean mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
+void mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
/*
* Signal handling