aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/tracebak.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/tracebak.c')
-rw-r--r--gcc/ada/tracebak.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/ada/tracebak.c b/gcc/ada/tracebak.c
index ff85ca5..dceac0d 100644
--- a/gcc/ada/tracebak.c
+++ b/gcc/ada/tracebak.c
@@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
- * Copyright (C) 2000-2015, Free Software Foundation, Inc. *
+ * Copyright (C) 2000-2016, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
@@ -99,6 +99,8 @@ extern void (*Unlock_Task) (void);
#include <windows.h>
+#define IS_BAD_PTR(ptr) (IsBadCodePtr((FARPROC)ptr))
+
int
__gnat_backtrace (void **array,
int size,
@@ -137,6 +139,10 @@ __gnat_backtrace (void **array,
}
else
{
+ /* If the last unwinding step failed somehow, stop here. */
+ if (IS_BAD_PTR(context.Rip))
+ break;
+
/* Unwind. */
memset (&NvContext, 0, sizeof (KNONVOLATILE_CONTEXT_POINTERS));
RtlVirtualUnwind (0, ImageBase, context.Rip, RuntimeFunction,