harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ibere...@apache.org
Subject svn commit: r663492 - in /harmony/enhanced/drlvm/trunk/vm/port/src: signals/linux/signals_common.cpp thread/include/port_thread_internal.h thread/linux/thread_os.c
Date Thu, 05 Jun 2008 07:36:10 GMT
Author: iberezhn
Date: Thu Jun  5 00:36:10 2008
New Revision: 663492

URL: http://svn.apache.org/viewvc?rev=663492&view=rev
Log:
Committed patch from HARMONY-5683
[drlvm][signals] H4265 reg test fails on Linux/x86


Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_common.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/include/port_thread_internal.h
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_os.c

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_common.cpp?rev=663492&r1=663491&r2=663492&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_common.cpp Thu Jun  5 00:36:10
2008
@@ -63,7 +63,11 @@
     {
     case SIGSEGV:
         if (tlsdata->restore_guard_page)
+        {
+            // Now it's safe to disable alternative stack
+            set_alt_stack(tlsdata, FALSE);
             result = port_process_signal(PORT_SIGNAL_STACK_OVERFLOW, pregs, fault_addr, FALSE);
+        }
         else
             result = port_process_signal(PORT_SIGNAL_GPF, pregs, fault_addr, FALSE);
         break;
@@ -222,6 +226,9 @@
         else
         { // To process signal on protected stack area
             port_thread_clear_guard_page();
+            // Note: the call above does not disable alternative stack
+            // It can't be made while we are on alternative stack
+            // Alt stack will be disabled explicitly in c_handler()
             tlsdata->restore_guard_page = TRUE;
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/include/port_thread_internal.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/include/port_thread_internal.h?rev=663492&r1=663491&r2=663492&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/include/port_thread_internal.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/include/port_thread_internal.h Thu Jun
 5 00:36:10 2008
@@ -159,6 +159,12 @@
 /* Detaches temporarily attached thread */
 int port_thread_detach_temporary();
 
+#ifndef WIN32
+/* To restore alternative stack out of signal handler on Linux */
+int set_alt_stack(port_tls_data_t* tlsdata, Boolean set);
+
+#endif
+
 
 #ifdef __cplusplus
 }

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_os.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_os.c?rev=663492&r1=663491&r2=663492&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_os.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_os.c Thu Jun  5 00:36:10
2008
@@ -203,10 +203,24 @@
     return res;
 }
 
+int set_alt_stack(port_tls_data_t* tlsdata, Boolean set)
+{
+    stack_t sigalt;
+
+    // sets alternative stack
+    sigalt.ss_sp = tlsdata->guard_stack_addr;
+    sigalt.ss_size = tlsdata->guard_stack_size;
+//#if defined(FREEBSD)
+    sigalt.ss_flags = set ? 0 : SS_DISABLE;
+//#else
+//    sigalt.ss_flags = set ? SS_ONSTACK : SS_DISABLE;
+//#endif
+    return sigaltstack(&sigalt, NULL);
+}
+
 static int set_guard_page(port_tls_data_t* tlsdata, Boolean set)
 {
     int res;
-    stack_t sigalt;
 
     if (!tlsdata)
         tlsdata = get_private_tls_data();
@@ -218,7 +232,7 @@
         return 0;
 
     if ((set && tlsdata->guard_page_set) ||
-         !set && !tlsdata->guard_page_set)
+        (!set && !tlsdata->guard_page_set))
         return 0; // Already in needed state
 
     res = mprotect(tlsdata->guard_page_addr, tlsdata->guard_page_size,
@@ -227,18 +241,13 @@
     if (res != 0)
         return errno;
 
-    // sets alternative stack
-    sigalt.ss_sp = tlsdata->guard_stack_addr;
-    sigalt.ss_size = tlsdata->guard_stack_size;
-//#if defined(FREEBSD)
-    sigalt.ss_flags = set ? 0 : SS_DISABLE;
-//#else
-//    sigalt.ss_flags = set ? SS_ONSTACK : SS_DISABLE;
-//#endif
-    res = sigaltstack(&sigalt, NULL);
+    if (set)
+    {
+        res = set_alt_stack(tlsdata, TRUE);
 
-    if (res != 0)
-        return errno;
+        if (res != 0)
+            return errno;
+    }
 
     tlsdata->guard_page_set = set;
     return 0;



Mime
View raw message