The type changes in struct Packfile break the pointer math used in a few places
to calculate the address of the end of the loaded byte code. This causes
segfaults in build_asm in jit.c when using -j. It also breaks the bounds
checking on opcode address in runops_slow_core.

The patch adds the necessary cast to correct the code_end calculations.

-- 
Jason
Index: interpreter.c
===================================================================
RCS file: /home/perlcvs/parrot/interpreter.c,v
retrieving revision 1.68
diff -u -r1.68 interpreter.c
--- interpreter.c       5 Feb 2002 09:20:07 -0000       1.68
+++ interpreter.c       14 Feb 2002 03:24:44 -0000
@@ -68,7 +68,7 @@
 
     code_start = (opcode_t *)interpreter->code->byte_code;
     code_size  = interpreter->code->byte_code_size;
-    code_end   = (opcode_t *)(interpreter->code->byte_code + code_size);
+    code_end   = (opcode_t *)((char *)interpreter->code->byte_code + code_size);
 
     pc = core(interpreter, pc);
 
@@ -294,7 +294,7 @@
 
     code_start = (opcode_t *)interpreter->code->byte_code;
     code_size  = interpreter->code->byte_code_size;
-    code_end   = (opcode_t *)(interpreter->code->byte_code + code_size);
+    code_end   = (opcode_t *)((char *)interpreter->code->byte_code + code_size);
 
     jit_code = build_asm(interpreter, pc, code_start, code_end);
 #ifdef ALPHA
@@ -345,7 +345,7 @@
 
     code_start = (opcode_t *)interpreter->code->byte_code;
     code_size  = interpreter->code->byte_code_size;
-    code_end   = (opcode_t *)(interpreter->code->byte_code + code_size);
+    code_end   = (opcode_t *)((char *)interpreter->code->byte_code + code_size);
 
     code_start_prederef = pc_prederef;
 
Index: runops_cores.c
===================================================================
RCS file: /home/perlcvs/parrot/runops_cores.c,v
retrieving revision 1.11
diff -u -r1.11 runops_cores.c
--- runops_cores.c      22 Jan 2002 16:57:25 -0000      1.11
+++ runops_cores.c      14 Feb 2002 03:24:44 -0000
@@ -49,7 +49,7 @@
 
     code_start = (opcode_t *)interpreter->code->byte_code;
     code_size  = interpreter->code->byte_code_size;
-    code_end   = (opcode_t *)(interpreter->code->byte_code + code_size);
+    code_end   = (opcode_t *)((char *)interpreter->code->byte_code + code_size);
 
     if (interpreter->flags & PARROT_TRACE_FLAG) {
       trace_op(interpreter, code_start, code_end, pc);

Reply via email to