Created
April 17, 2012 08:30
-
-
Save arnsholt/2404545 to your computer and use it in GitHub Desktop.
P6int.c segfault
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) run cstruct.pl | |
Starting program: /Users/arne/programming/perl/rakudo/perl6 cstruct.pl | |
Reading symbols for shared libraries .+++++++++....... done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
Reading symbols for shared libraries . done | |
created | |
set | |
4 | |
alive | |
array | |
set | |
Program received signal EXC_BAD_ACCESS, Could not access memory. | |
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 | |
get_int (interp=0x101808a30, st=0x105930ff0, data=0x0) at P6int.c:59 | |
59 static INTVAL get_int(PARROT_INTERP, STable *st, void *data) { | |
(gdb) p data | |
$1 = (void *) 0x0 | |
(gdb) p st | |
$2 = (STable *) 0x105930ff0 | |
(gdb) bt | |
#0 get_int (interp=0x101808a30, st=0x105930ff0, data=0x0) at P6int.c:59 | |
#1 0x000000010192e904 in Parrot_repr_at_pos_int_i_p_i (cur_opcode=0x107c96330, interp=0x101808a30) at nqp_ops.c:14207 | |
#2 0x0000000100078ce2 in runops_fast_core () | |
#3 0x000000010007898a in runops_int () | |
#4 0x000000010005dd27 in runops () | |
#5 0x0000000100059110 in Parrot_pcc_invoke_from_sig_object () | |
#6 0x0000000101905bb3 in decontainerize (interp=0x101808a30, var=0x106cb0978) at sixmodelobject.c:72 | |
#7 0x000000010190795b in Parrot_SixModelObject_find_method (interp=0x101808a30, _self=<value temporarily unavailable, due to optimizations>, name=0x1035c06b8) at sixmodelobject.c:298 | |
#8 0x000000010002634b in Parrot_callmethodcc_p_sc () | |
#9 0x0000000100078ce2 in runops_fast_core () | |
#10 0x000000010007898a in runops_int () | |
#11 0x000000010005dd27 in runops () | |
#12 0x0000000100059110 in Parrot_pcc_invoke_from_sig_object () | |
#13 0x0000000100049b23 in Parrot_ext_call () | |
#14 0x0000000100148bbc in Parrot_Task_invoke () | |
#15 0x000000010005907f in Parrot_pcc_invoke_from_sig_object () | |
#16 0x0000000100049b23 in Parrot_ext_call () | |
#17 0x000000010007d574 in Parrot_cx_outer_runloop () | |
#18 0x000000010007d64b in Parrot_cx_begin_execution () | |
#19 0x00000001000857e3 in Parrot_pf_execute_bytecode_program () | |
#20 0x00000001000443ac in Parrot_api_run_bytecode () | |
#21 0x00000001000016aa in main () | |
(gdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Binds the given value to the specified attribute. */ | |
static void bind_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) { | |
CStructREPRData *repr_data = (CStructREPRData *)st->REPR_data; | |
CStructBody *body = (CStructBody *)data; | |
STRING *type_str = Parrot_str_new_constant(interp, "type"); | |
STRING *carray_str = Parrot_str_new_constant(interp, "CArray"); | |
INTVAL slot; | |
/* Try to find the slot. */ | |
slot = hint >= 0 ? hint : | |
try_get_slot(interp, repr_data, class_handle, name); | |
if (slot >= 0) { | |
STable *st = repr_data->flattened_stables[slot]; | |
if (st) | |
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, | |
"CStruct Can't perform boxed bind on flattened attributes yet"); | |
else { | |
INTVAL placement = repr_data->attribute_locations[slot] & CSTRUCT_ATTR_MASK; | |
INTVAL real_slot = repr_data->attribute_locations[slot] >> CSTRUCT_ATTR_SHIFT; | |
if(IS_CONCRETE(value)) { | |
PMC *value_type = STABLE(value)->WHAT; | |
void *cobj = NULL; | |
body->child_objs[real_slot] = value; | |
/* Set cobj to correct pointer based on type of value. */ | |
if(STRING_equal(interp, REPR(value_type)->name, carray_str)) { | |
cobj = ((CArrayInstance *) value)->body.storage; | |
} | |
set_ptr_at_offset(body->cstruct, repr_data->struct_offsets[slot], cobj); | |
} | |
else { | |
body->child_objs[real_slot] = NULL; | |
set_ptr_at_offset(body->cstruct, repr_data->struct_offsets[slot], NULL); | |
} | |
} | |
} | |
else { | |
/* Otherwise, complain that the attribute doesn't exist. */ | |
no_such_attribute(interp, "bind", class_handle, name); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use NativeCall; | |
class Test is repr('CStruct') { | |
has int32 $.native; | |
#has CArray[int32] $.obj; | |
has CArray $.obj; | |
method set(int32 $val) { | |
$!native = $val; | |
} | |
method arr(CArray $val) { | |
$!obj := $val; | |
} | |
} | |
my Test $foo .= new(); | |
say('created'); | |
$foo.set(4); | |
say('set'); | |
say $foo.native; | |
say('alive'); | |
my $arr = CArray[int32].new(); | |
$arr[0] = 1; | |
$arr[1] = 2; | |
$arr[2] = 3; | |
say('array'); | |
$foo.arr($arr); | |
say('set'); | |
say($foo.obj[2]); | |
say('alive'); | |
# vim:ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment