method->args_count should be used to get the size of arguments,
not nr_args(args_list). This bug led to stack overflow with the
following code:
public class Test {
public void c(long x) {
}
public static void main(String[] args) {
Test t = new Test();
int x = 0;
while (x == 0) t.c(1l);
}
}
Signed-off-by: Tomek Grabiec <[email protected]>
---
arch/x86/insn-selector_32.brg | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index 6c9840f..17ed19c 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -756,9 +756,8 @@ reg: EXPR_INVOKEINTERFACE(arg) 1
/* invoke method */
select_insn(s, tree, reg_insn(INSN_CALL_REG, call_target));
- args_count = nr_args(to_expr(expr->args_list));
- if (args_count)
- method_args_cleanup(s, tree, args_count);
+ if (method->args_count)
+ method_args_cleanup(s, tree, method->args_count);
select_insn(s, tree, reg_reg_insn(INSN_MOV_REG_REG, eax, state->reg1));
if (edx != NULL)
@@ -1962,6 +1961,7 @@ static void invokevirtual(struct _MBState *state, struct
basic_block *s, struct
struct var_info *call_target;
unsigned long method_offset;
unsigned long args_count;
+ struct vm_method *method;
expr = to_expr(tree);
method_offset = expr_method_index(expr) * sizeof(void *);
@@ -1988,9 +1988,10 @@ static void invokevirtual(struct _MBState *state, struct
basic_block *s, struct
/* invoke method */
select_insn(s, tree, reg_insn(INSN_CALL_REG, call_target));
- args_count = nr_args(to_expr(expr->args_list));
- if (args_count)
- method_args_cleanup(s, tree, args_count);
+ method = expr->target_method;
+
+ if (method->args_count)
+ method_args_cleanup(s, tree, method->args_count);
}
static void emit_code(struct basic_block *bb, MBState *state, int goal)
--
1.6.0.6
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel