[aarch64-port-dev ] Fix SEGV on stack overflow check

Edward Nevill ed at camswl.com
Mon Nov 18 03:26:05 PST 2013


Hi,

The following test,

public class Overflow {

    public static int notInlineableSeries(int i)
    {
        int j = i;
        if (i == 0)
            return j;
        if ((j & 1) != 0)
            j += notInlineableSeries(i - 1);
        else
            j += 1 + notInlineableSeries(i - 1);
        return j;
    }

  public static void main(String[] args) {
     System.out.println(notInlineableSeries(1000000000));
  }
}

generates a SEGV when run

java -server

The following patch fixes this.

This moves the save of fp & lr to after the stack check in keeping with what is done for the client compiler.

OK to push?
Ed

--- CUT HERE ---
exporting patch:
# HG changeset patch
# User Edward Nevill edward.nevill at linaro.org
# Date 1384773608 0
#      Mon Nov 18 11:20:08 2013 +0000
# Node ID a9d5d7492f2fae53baccde69e7a6b4ce00cf77c7
# Parent  65546f5b752a425c5ad1f4c6859dc6c0c6d198bd
Move stack overflow check before create of frame

diff -r 65546f5b752a -r a9d5d7492f2f src/cpu/aarch64/vm/aarch64.ad
--- a/src/cpu/aarch64/vm/aarch64.ad	Fri Nov 15 07:44:18 2013 -0500
+++ b/src/cpu/aarch64/vm/aarch64.ad	Mon Nov 18 11:20:08 2013 +0000
@@ -904,12 +904,13 @@
   // insert a nop at the start of the prolog so we can patch in a
   // branch if we need to invalidate the method later
   __ nop();
+
+  if (C->need_stack_bang(framesize))
+    __ generate_stack_overflow_check(framesize);
+
   // push lr and rfp to create a frame
   __ stp(rfp, lr, Address(__ pre(sp, -2 * wordSize)));
 
-  if (C->need_stack_bang(framesize))
-    __ generate_stack_overflow_check(framesize);
-
   // allow for already pushed values
   framesize -= 2 * wordSize;
 
--- CUT HERE ---





More information about the aarch64-port-dev mailing list