#!/bin/env parrot
#
# yieldbug.imc
#
# This program should print dots forever.
# Instead it prints a few dots and then segfaults.
#
# parrot -t shows this bug:
#
#    parrot: src/stacks.c:95: stack_height:
#    Assertion `height == (top->n_chunks - 1) * 256 + top->used' failed.
#    Aborted
#
# It works fine if I comment out the set_eh line.
# Can anyone help here?
#
# (Sorry for the long listing. It's as short as I could make it.)
#
# - Michal
#

.sub __main__
    .local Continuation retcon
    .local Coroutine it
    .local object res

    # create an exception handler. (this is the problem)
    newsub $P0, .Exception_Handler, _on_exception
    set_eh $P0

    # it doesn't matter whether this comes before or
    # after the exception handler
    newsub it, .Coroutine, _iterator_logic

    # main loop:
    loop0:
        savetop
        newsub retcon, .Continuation, return
        .pcc_begin non_prototyped
        .pcc_call it
    return:
        .result res
        .pcc_end
        print res
    goto loop0
.end


# this iterator just yields dots forever:
.pcc_sub _iterator_logic non_prototyped
    .local object dot
    loop:
        dot = new PerlString
        dot = '.'
        .pcc_begin_yield
            .return dot
        .pcc_end_yield
    goto loop
.end


# note that this is never actually invoked:
.pcc_sub _on_exception non_prototyped
    end
    .pcc_begin_return
    .pcc_end_return
.end


# Sincerely,
#
# Michal J Wallace
# Sabren Enterprises, Inc.
# -------------------------------------
# contact: [EMAIL PROTECTED]
# hosting: http://www.cornerhost.com/
# my site: http://www.withoutane.com/
# --------------------------------------

Reply via email to