harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r467552 - in /incubator/harmony/enhanced/drlvm/trunk/vm: tests/smoke/StackTest.java vmcore/src/util/ia32/base/compile_IA32.cpp vmcore/src/util/linux/signals_ia32.cpp vmcore/src/util/win/ia32/nt_exception_filter.cpp
Date Wed, 25 Oct 2006 03:55:32 GMT
Author: wjwashburn
Date: Tue Oct 24 20:55:30 2006
New Revision: 467552

URL: http://svn.apache.org/viewvc?view=rev&rev=467552
Log:
HARMONY-1786, a patch to fix Stack Overflow Error detection on Linux
smoke tests pass on both Linux and WindowsXP


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java?view=diff&rev=467552&r1=467551&r2=467552
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java Tue Oct 24 20:55:30
2006
@@ -15,10 +15,6 @@
  *  limitations under the License.
  */
 
-/*
- *  $$$ GMJ
- *  @keyword XXX_StackOverflowBroken
- */
 public class StackTest {
 
     static int depth = 0;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp?view=diff&rev=467552&r1=467551&r2=467552
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp Tue
Oct 24 20:55:30 2006
@@ -1,4 +1,4 @@
-/*
+/* 
  *  Licensed to the Apache Software Foundation (ASF) under one or more
  *  contributor license agreements.  See the NOTICE file distributed with
  *  this work for additional information regarding copyright ownership.
@@ -88,6 +88,9 @@
     unsigned cur_word = 0;
     for(unsigned i=0; i<num_args; i++) {
         Type_Info_Handle tih = method_args_get_type_info(msh, i);
+        bool is_magic = false;  //wjw, MMTk support
+        const String *str = tih->get_type_name();
+
         switch (type_info_get_type(tih)) {
         case VM_DATA_TYPE_INT64:
         case VM_DATA_TYPE_UINT64:
@@ -110,6 +113,19 @@
             break;
         case VM_DATA_TYPE_CLASS:
         case VM_DATA_TYPE_ARRAY:
+            if (str) {   //wjw MMTk support
+                if (strncmp(str->bytes, "org/vmmagic/unboxed/Address", str->len) ==
0 ) 
+                     is_magic = true;
+                if (strncmp(str->bytes, "org/vmmagic/unboxed/Extent",  str->len) ==
0 ) 
+                     is_magic = true;
+                if (strncmp(str->bytes, "org/vmmagic/unboxed/Offset",  str->len) ==
0 ) 
+                     is_magic = true;
+                if (strncmp(str->bytes, "org/vmmagic/unboxed/Word",    str->len) ==
0 ) 
+                     is_magic = true;
+                if (strncmp(str->bytes, "org/vmmagic/unboxed/ObjectReference",    str->len)
== 0 ) 
+                     is_magic = true;
+            }
+            if (is_magic == false)
             gc->add_object((ManagedObject**)get_arg_word(num_arg_words, cur_word));
             cur_word++;
             break;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp?view=diff&rev=467552&r1=467551&r2=467552
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp Tue Oct
24 20:55:30 2006
@@ -78,6 +78,8 @@
 static int sc_nest = -1;
 static uint32 exam_point;
 
+
+
 void linux_ucontext_to_regs(Registers* regs, ucontext_t *uc)
 {
     regs->eax = uc->uc_mcontext.gregs[REG_EAX];
@@ -150,16 +152,13 @@
 
     uint32 exception_esp = regs.esp;
     DebugUtilsTI* ti = VM_Global_State::loader_env->TI;
-
     exn_athrow_regs(&regs, exc_clss);
-
     assert(exception_esp <= regs.esp);
     if (ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_EXCEPTION_EVENT)) {
         regs.esp = regs.esp - 4;
         *((uint32*) regs.esp) = regs.eip;
         regs.eip = ((uint32)asm_jvmti_exception_catch_callback);
     }
-
     linux_regs_to_ucontext(uc, &regs);
 }
 
@@ -272,6 +271,7 @@
 
 inline size_t find_guard_stack_size() {
     return 64*1024;
+    
 }
 
 inline size_t find_guard_page_size() {
@@ -318,34 +318,39 @@
 void set_guard_stack() {
     int err;
     
-    /*
-     * have the stack parameters been initialized?
-     * 
-     * TODO - fix this - this probably should be elsewhere
-     */
-
-    if(!p_TLS_vmthread->stack_addr) {
-        init_stack_info();
-    }
-    
     char* stack_addr = (char*) get_stack_addr();
     size_t stack_size = get_stack_size();
     size_t guard_stack_size = get_guard_stack_size();
     size_t guard_page_size = get_guard_page_size();
 
-    err = mprotect(stack_addr - stack_size + guard_page_size + guard_stack_size,
-        guard_page_size, PROT_NONE);
+    // map the guard page and protect it
+    void UNUSED *res = mmap(stack_addr - stack_size + guard_page_size +
+    guard_stack_size, guard_page_size,  PROT_READ | PROT_WRITE,
+    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+    assert(res!=MAP_FAILED);
+
+    err = mprotect(stack_addr - stack_size  + guard_page_size +  
+    guard_stack_size, guard_page_size, PROT_NONE );
+   
+    assert(!err);
+
+    //map the alternate stack on which we want to handle the signal
+    void UNUSED *res2 = mmap(stack_addr - stack_size + guard_page_size,
+    guard_stack_size,  PROT_READ | PROT_WRITE,
+    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+    assert(res2!=MAP_FAILED);
+
 
-/* $$$ GMJ    assert(!err);  */
-    
     stack_t sigalt;
     sigalt.ss_sp = stack_addr - stack_size + guard_page_size;
     sigalt.ss_flags = SS_ONSTACK;
     sigalt.ss_size = guard_stack_size;
 
     err = sigaltstack (&sigalt, NULL);
-    
     assert(!err);
+
 }
 
 size_t get_available_stack_size() {
@@ -376,8 +381,10 @@
     size_t guard_stack_size = get_guard_stack_size();
     size_t guard_page_size = get_guard_page_size();
 
-    err = mprotect(stack_addr - stack_size + guard_page_size + guard_stack_size,
-        guard_page_size, PROT_READ | PROT_WRITE);
+
+    err = mprotect(stack_addr - stack_size + guard_page_size +
+    guard_stack_size, guard_page_size, PROT_READ | PROT_WRITE);
+
 
     stack_t sigalt;
     sigalt.ss_sp = stack_addr - stack_size + guard_page_size;
@@ -385,6 +392,7 @@
     sigalt.ss_size = guard_stack_size;
 
     err = sigaltstack (&sigalt, NULL);
+
 }
 
 bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
@@ -395,6 +403,7 @@
 
     char* guard_page_begin = stack_addr - stack_size + guard_page_size + guard_stack_size;
     char* guard_page_end = guard_page_begin + guard_page_size;
+
     char* fault_addr = (char*)(info->si_addr);
     //char* esp_value = (char*)(uc->uc_mcontext.gregs[REG_ESP]);
 
@@ -432,7 +441,7 @@
 }
 
 void null_java_reference_handler(int signum, siginfo_t* UNREF info, void* context)
-{
+{ 
     ucontext_t *uc = (ucontext_t *)context;
     Global_Env *env = VM_Global_State::loader_env;
 
@@ -443,7 +452,7 @@
         stack_overflow_handler(signum, info, context);
         return;
     }
-
+     
     if (env->shutting_down != 0) {
         fprintf(stderr, "null_java_reference_handler(): called in shutdown stage\n");
     } else if (!interpreter_enabled()) {
@@ -452,7 +461,6 @@
             return;
         }
     }
-
     fprintf(stderr, "SIGSEGV in VM code.\n");
     Registers regs;
     linux_ucontext_to_regs(&regs, uc);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp?view=diff&rev=467552&r1=467551&r2=467552
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
Tue Oct 24 20:55:30 2006
@@ -176,17 +176,6 @@
 }
 
 void set_guard_stack() {
-    
-    /*
-     * have the stack parameters been initialized?
-     * 
-     * TODO - fix this - this probably should be elsewhere
-     */
-
-    if(!p_TLS_vmthread->stack_addr) {
-        init_stack_info();
-    }
-  
     void* stack_addr = get_stack_addr();
     size_t stack_size = get_stack_size();
     size_t page_size = get_guard_page_size();



Mime
View raw message