# New Ticket Created by  Christoph Otto 
# Please include the string:  [perl #60556]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60556 >


If an exception handler catches an exception from a MULTI function implemented 
in C, passing that exception from the handler to a sub causes a segfault. 
Doing the same thing with a subclass of Integer with a PIR divide sub works as 
expected.
The attached code demonstrates this.  If p is an Integer, the parrot dies.  If 
it's a MyInteger, it doesn't.
#! parrot

.sub main :main

    .local pmc p, q, int_class, myint_class

    int_class   = get_class 'Integer'
    myint_class = subclass int_class, 'MyInteger'

    p = new 'Integer'
    set p, "0"

    push_eh handler
    #throw an exception from a C-level MULTI function
    q = p / p
    goto end
    pop_eh
    goto end

handler:
    .local pmc exception
    .local string message
    .get_results (exception)

    message = exception['message']
    cause_sf(message)
end:    
.end

.sub cause_sf 
    .param string message
    say message
end:    
.end

.namespace ['MyInteger'] 

.sub divide :multi(MyInteger, MyInteger)
    .param pmc self
    .param pmc right
    .param pmc dest

    .local pmc ex

    ex = new 'Exception'
    ex['message'] = "don't feel like dividing"
    throw ex
.end

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 filetype=pir:

Reply via email to