[newlib-cygwin] Disable fetching heap info on 64 bit XP/2003

Corinna Vinschen corinna@sourceware.org
Sun Jul 5 10:53:00 GMT 2015


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e426213a88e060ae3d739a8d9fe2f3e7e0432e43

commit e426213a88e060ae3d739a8d9fe2f3e7e0432e43
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Sun Jul 5 12:51:52 2015 +0200

    Disable fetching heap info on 64 bit XP/2003
    
            * fhandler_process.cc (heap_info::heap_info): Disable fetching heap info
            on 64 bit XP/2003.  Explain why.
            * wincap.h (wincaps::has_broken_rtl_query_process_debug_information):
            New element.
            * wincap.cc: Implement above element throughout.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/ChangeLog           |  8 ++++++++
 winsup/cygwin/fhandler_process.cc |  6 +++++-
 winsup/cygwin/release/2.1.0       |  2 ++
 winsup/cygwin/wincap.cc           | 10 ++++++++++
 winsup/cygwin/wincap.h            |  2 ++
 5 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 840f396..a1f4957 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2015-07-05  Corinna Vinschen  <corinna@vinschen.de>
+
+	* fhandler_process.cc (heap_info::heap_info): Disable fetching heap info
+	on 64 bit XP/2003.  Explain why.
+	* wincap.h (wincaps::has_broken_rtl_query_process_debug_information):
+	New element.
+	* wincap.cc: Implement above element throughout.
+
 2015-07-04  Corinna Vinschen  <corinna@vinschen.de>
 
 	* autoload.cc (SetThreadStackGuarantee): Import.
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 161050b..d3ee874 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -592,7 +592,11 @@ struct heap_info
     NTSTATUS status;
     PDEBUG_HEAP_ARRAY harray;
 
-    buf = RtlCreateQueryDebugBuffer (0, FALSE);
+    /* FIXME?  RtlQueryProcessDebugInformation/CreateToolhelp32Snapshot both
+       crash the target process on 64 bit XP/2003 in native 64 bit mode. */
+    if (wincap.has_broken_rtl_query_process_debug_information ())
+      return;
+    buf = RtlCreateQueryDebugBuffer (16 * 65536, FALSE);
     if (!buf)
       return;
     status = RtlQueryProcessDebugInformation (pid, PDI_HEAPS | PDI_HEAP_BLOCKS,
diff --git a/winsup/cygwin/release/2.1.0 b/winsup/cygwin/release/2.1.0
index 93b84b9..da484f5 100644
--- a/winsup/cygwin/release/2.1.0
+++ b/winsup/cygwin/release/2.1.0
@@ -25,3 +25,5 @@ Bug Fixes
 
 - Fix fork failing after the parent recovered from a stack overflow.
   Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00384.html
+
+- Fix a crash on 64 bit XP/2003 when opening /proc/$PID/maps.
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 2c5880e..8e07661 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -48,6 +48,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:false,
   has_microsoft_accounts:false,
   has_set_thread_stack_guarantee:false,
+  has_broken_rtl_query_process_debug_information:false,
 };
 
 wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
@@ -78,6 +79,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:false,
   has_microsoft_accounts:false,
   has_set_thread_stack_guarantee:true,
+  has_broken_rtl_query_process_debug_information:true,
 };
 
 wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
@@ -108,6 +110,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:false,
   has_microsoft_accounts:false,
   has_set_thread_stack_guarantee:true,
+  has_broken_rtl_query_process_debug_information:false,
 };
 
 wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
@@ -138,6 +141,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:false,
   has_microsoft_accounts:false,
   has_set_thread_stack_guarantee:true,
+  has_broken_rtl_query_process_debug_information:false,
 };
 
 wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
@@ -168,6 +172,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:true,
   has_microsoft_accounts:true,
   has_set_thread_stack_guarantee:true,
+  has_broken_rtl_query_process_debug_information:false,
 };
 
 wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = {
@@ -198,6 +203,7 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = {
   has_precise_system_time:true,
   has_microsoft_accounts:true,
   has_set_thread_stack_guarantee:true,
+  has_broken_rtl_query_process_debug_information:false,
 };
 
 wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
@@ -255,6 +261,10 @@ wincapc::init ()
   /* 64 bit systems have one more guard page than their 32 bit counterpart. */
   ++((wincaps *)caps)->def_guard_pages;
 #else
+  /* RtlQueryProcessDebugInformation/CreateToolhelp32Snapshot both crash the
+     target process on 64 bit XP/2003 in native 64 bit mode only.  Reset the
+     flag here for 32 bit. */
+  ((wincaps *)caps)->has_broken_rtl_query_process_debug_information = false;
   if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
 					     ProcessWow64Information,
 					     &wow64, sizeof wow64, NULL))
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 160085d..1d5cfda 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -41,6 +41,7 @@ struct wincaps
   unsigned has_precise_system_time			: 1;
   unsigned has_microsoft_accounts			: 1;
   unsigned has_set_thread_stack_guarantee		: 1;
+  unsigned has_broken_rtl_query_process_debug_information : 1;
 };
 
 class wincapc
@@ -96,6 +97,7 @@ public:
   bool	IMPLEMENT (has_precise_system_time)
   bool	IMPLEMENT (has_microsoft_accounts)
   bool	IMPLEMENT (has_set_thread_stack_guarantee)
+  bool	IMPLEMENT (has_broken_rtl_query_process_debug_information)
 
 #undef IMPLEMENT
 };



More information about the Cygwin-cvs mailing list