id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,lang,patch,platform
472,segfault when catching an exception from C,fperrad,whiteknight,"since Parrot 0.8.0 (Exception refactor ?)

Lua works fine when exception comes from PIR (die $S0), but segfaults when exception comes from C (PMC in fact).

 $ cat add.lua [[BR]]
     print (42 + nil)

When the exception catching in 'docall' (luaaux.pir) is disabled, the result is normal :

 $ parrot lua.pbc add.lua [[BR]]
attempt to perform arithmetic on a nil value [[BR]]
current instr.: '&main_10' pc -339049740 ((unknown file):-1) [[BR]]
called from Sub '&main_10' pc 93 (EVAL_1:36) [[BR]]
called from Sub 'docall' pc 53207 (src/lib/luaaux.pir:997) [[BR]]
called from Sub 'handle_script' pc 50993 (lua.pir:303) [[BR]]
called from Sub 'main' pc 50480 (lua.pir:123) [[BR]]

otherwise, parrot segfaults with the following back trace :

#0  0xb7b384b5 in clone_key_arg (interp=0x804f040, st=0xbfaf6168) at
src/call/pcc.c:1191 [[BR]]
#1  0xb7b38b2f in Parrot_convert_arg (interp=0x804f040, st=0xbfaf6168) at src/call/pcc.c:1817 [[BR]]
#2  0xb7b3973d in Parrot_process_args (interp=0x804f040,
st=0xbfaf6168, param_or_result=PARROT_PASS_PARAMS) at src/call pcc.c:1694 [[BR]]
#3  0xb7b39c68 in parrot_pass_args (interp=0x804f040,
src_ctx=0x83a1ad0, dest_ctx=0x8247938, src_indexes=0xb77030b8, dest_indexes=0xbfaf623c, param_or_result=PARROT_PASS_PARAMS) at
src/call/pcc.c:1884 [[BR]]
#4  0xb7ca5ec4 in Parrot_Exception_nci_backtrace (interp=0x804f040,
pmc=0x80aa810) at /home/fperrad/checkout/parrot/tools/build/../../lib/Parrot/Pmc2c/PCCMETHOD.pm:442 [[BR]]
#5  0xb7cca04b in Parrot_NCI_invoke (interp=0x804f040, pmc=0x80aa810, next=0xb77030dc) at ./src/pmc/nci.pmc:330 [[BR]]
#6  0xb7ac7e1d in Parrot_callmethodcc_p_sc (cur_opcode=0xb77030d0,
interp=0x804f040) at src/ops/object.ops:80 [[BR]]
#7  0xb7b7a029 in runops_slow_core (interp=0x804f040, pc=0xb77030d0)
at src/runops_cores.c:461 [[BR]]
#8  0xb7b3e8d0 in runops_int (interp=0x804f040, offset=53220) at
src/interpreter.c:980 [[BR]]
#9  0xb7b3f501 in runops (interp=0x804f040, offs=53220) at src/call/ops.c:107 [[BR]]
#10 0xb7b3f7e8 in runops_args (interp=0x804f040, sub=0x80eeaf8,
obj=0x80b0358, meth_unused=0x0, sig=0xb7e17aac ""vP"", ap=0xbfaf6498 ""` \016\b"") at src/call/ops.c:254 [[BR]]
#11 0xb7b4064d in Parrot_runops_fromc_args (interp=0x804f040,
sub=0x80eeaf8, sig=0xb7e17aac ""vP"") at src/call/ops.c:321 [[BR]]
#12 0xb7b20bc0 in Parrot_ex_throw_from_c (interp=0x804f040,
exception=0x80edd60) at src/exceptions.c:341 [[BR]]
#13 0xb7b20d05 in Parrot_ex_throw_from_c_args (interp=0x804f040,
ret_addr_unused=0x0, exitcode=37, format=0xb76c1990 ""attempt to perform arithmetic on a %Ss value"")
at src/exceptions.c:410 [[BR]]
#14 0xb76a81cd in Parrot_LuaNumber_multi_add_DEFAULT_PMC
(interp=0x804f040, pmc=0x80ee618, value=0x80ede80, dest=0x0) at ./luanumber.pmc:338 [[BR]]
#15 0x080c4131 in ?? () [[BR]]
#16 0x0804f040 in ?? () [[BR]]
#17 0x080ee618 in ?? () [[BR]]
#18 0x080ede80 in ?? () [[BR]]
#19 0x00000000 in ?? () [[BR]]
(gdb) [[BR]]

",bug,closed,critical,,core,,high,fixed,,,lua,,
