Discussion:
[perl #59968] [BUG] Calling Test::More sub after catching a div by zero exception segfaults
(too old to reply)
Mark Grimes
2008-10-17 23:10:40 UTC
Permalink
# New Ticket Created by Mark Grimes
# Please include the string: [perl #59968]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59968 >


The following code results in a segfault:

.sub main :main
.include 'include/test_more.pir'

new P0, 'Integer'
new P2, 'Integer'
new P1, 'Integer'

set P0, 1
set P2, 0

ok( 1, 'ready...' )

push_eh handler
P1 = P0 / P2
ok( 0, "not caught" )
end
pop_eh
handler:
ok( 1, 'caught' ) # segfaults
# say "ok" # no problem with this
.end

The ok() line will segfault, but if it is replaced by the "say" line,
all is well. If we use I0, I1, I2 instead of the Integer PMC's, it
works find, as well.

Thanks,
Mark
Will Coleda
2009-02-01 00:43:05 UTC
Permalink
You can't use "P0" as a register in PIR these days, you need "$P0" instead.

On Sat, Jan 31, 2009 at 7:22 PM, James Keenan via RT
$ cat seg.pir
.sub main :main
.include 'include/test_more.pir'
new P0, 'Integer'
new P2, 'Integer'
new P1, 'Integer'
set P0, 1
set P2, 0
ok( 1, 'ready...' )
push_eh handler
P1 = P0 / P2
ok( 0, "not caught" )
end
pop_eh
ok( 1, 'caught' ) # segfaults
# say "ok" # no problem with this
.end
[li11-226:parrot] 522 $ ./parrot seg.pir
error:imcc:'P0' is only a valid register name in PASM mode
in file 'seg.pir' line 4
Can anyone comment?
Thank you very much.
kid51
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev
--
Will "Coke" Coleda
Francois Perrad
2009-03-22 14:42:01 UTC
Permalink
Thanks. Making that correction, I confirm that the OP's seg fault still
$ cat seg.pir
.sub main :main
.include 'include/test_more.pir'
new $P0, 'Integer'
new $P2, 'Integer'
new $P1, 'Integer'
set $P0, 1
set $P2, 0
ok( 1, 'ready...' )
push_eh handler
$P1 = $P0 / $P2
ok( 0, "not caught" )
end
pop_eh
ok( 1, 'caught' ) # segfaults
# say "ok" # no problem with this
.end
# mode: pir
# fill-column: 100
$ ./parrot seg.pir
ok 1 - ready...
Segmentation fault
Still segfaulting in r37615.
Here's the backtrace.
#0 0x010925ef in clone_key_arg (interp=0x2300da0, st=0xbfffc618) at src/call/pcc.c:1191
#1 0x01092729 in Parrot_convert_arg (interp=0x2300da0, st=0xbfffc618) at
src/call/pcc.c:1817
#2 0x01093792 in Parrot_process_args (interp=0x2300da0, st=0xbfffc618,
param_or_result=PARROT_PASS_PARAMS) at src/call/pcc.c:1694
#3 0x01093cc2 in parrot_pass_args (interp=0x2300da0, src_ctx=0x2324a70,
dest_ctx=0x233bce0, src_indexes=0x2327488, dest_indexes=0x3591fc,
param_or_result=PARROT_PASS_PARAMS) at src/call/pcc.c:1884
#4 0x0100fd10 in Parrot_get_params_pc (cur_opcode=0x3591fc, interp=0x2300da0) at
src/ops/core.ops:615
#5 0x010e68f3 in runops_slow_core (interp=0x2300da0, pc=0x3591fc) at
src/runops_cores.c:461
#6 0x01099bc5 in runops_int (interp=0x2300da0, offset=66) at src/interpreter.c:980
#7 0x0109a651 in runops (interp=0x2300da0, offs=66) at src/call/ops.c:107
#8 0x0109a917 in runops_args (interp=0x2300da0, sub=0x370750, obj=0x28354b0,
meth_unused=0x0, sig=0x12eddc8 "vP", ap=0xbfffc87c "x\0067") at src/call/ops.c:254
#9 0x0109b759 in Parrot_runops_fromc_args (interp=0x2300da0, sub=0x370750,
sig=0x12eddc8 "vP") at src/call/ops.c:321
#10 0x0107b775 in Parrot_ex_throw_from_c (interp=0x2300da0, exception=0x370678) at
src/exceptions.c:341
#11 0x0107bd4f in Parrot_ex_throw_from_c_args (interp=0x2300da0,
ret_addr_unused=0x0, exitcode=30, format=0x131cddc "float division by zero") at
src/exceptions.c:410
#12 0x011beec5 in Parrot_Integer_multi_divide_DEFAULT_PMC (interp=0x2300da0,
pmc=0x32b8e8, value=0x32b858, dest=0x32b828) at ./src/pmc/integer.pmc:805
#13 0x010a8bae in pcf_P_JPPP (interp=0x2300da0, self=0x283dc90) at src/nci.c:609
#14 0x011b18a9 in Parrot_NCI_invoke (interp=0x2300da0, pmc=0x283dc90, next=0x0) at
./src/pmc/nci.pmc:330
#15 0x0109635f in Parrot_pcc_invoke_from_sig_object (interp=0x2300da0,
sub_obj=0x283dc90, sig_obj=0x370720) at src/call/pcc.c:2980
#16 0x010a6dfc in Parrot_mmd_multi_dispatch_from_c_args (interp=0x2300da0,
name=0x12ec650 "divide", sig=0x1301048 "PPP->P") at src/multidispatch.c:340
#17 0x0117d1f4 in Parrot_default_divide (interp=0x2300da0, pmc=0x32b8e8,
value=0x32b858, dest=0x32b828) at ./src/pmc/default.pmc:1473
#18 0x01023aa0 in Parrot_div_p_p_p (cur_opcode=0x2327444, interp=0x2300da0) at
src/ops/math.ops:402
#19 0x010e68f3 in runops_slow_core (interp=0x2300da0, pc=0x2327444) at
src/runops_cores.c:461
#20 0x01099bc5 in runops_int (interp=0x2300da0, offset=0) at src/interpreter.c:980
#21 0x0109a651 in runops (interp=0x2300da0, offs=0) at src/call/ops.c:107
#22 0x0109a917 in runops_args (interp=0x2300da0, sub=0x32ef78, obj=0x28354b0,
meth_unused=0x0, sig=0x12eddc8 "vP", ap=0xbfffed2c "`?2") at src/call/ops.c:254
#23 0x0109b759 in Parrot_runops_fromc_args (interp=0x2300da0, sub=0x32ef78,
sig=0x12eddc8 "vP") at src/call/ops.c:321
#24 0x01077d8e in Parrot_runcode (interp=0x2300da0, argc=1, argv=0xbfffee80) at
src/embed.c:1011
#25 0x012d2caf in imcc_run_pbc (interp=0x2300da0, obj_file=0, output_file=0x0, argc=1,
argv=0xbfffee80) at compilers/imcc/main.c:798
#26 0x012d3936 in imcc_run (interp=0x2300da0, sourcefile=0xbfffef5f "foo.pir", argc=1,
argv=0xbfffee80) at compilers/imcc/main.c:1085
#27 0x000029b8 in main (argc=1, argv=0xbfffee80) at src/main.c:61
The program is running. Exit anyway? (y or n)
Look like https://trac.parrot.org/parrot/ticket/472

François.
--
Will "Coke" Coleda
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev
Loading...