Ticket #1151 (closed bug: duplicate)

Opened 5 years ago

Last modified 3 years ago

Exception thrown from constructor leads to oddness

Reported by: coke Owned by:
Priority: normal Milestone:
Component: none Version: trunk
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

This code should generate:

ok #test exception from init vtable

but instead generates

ok #test exception from init vtable
not No handler to delete.
.sub main :main
.local pmc type
newclass type, 'Parent'

.local pmc obj, exception
.local string message
message = 'no error'
push_eh handler
obj = new 'Parent'
print 'not '
pop_eh
goto finally

handler:
.get_results(exception)
pop_eh
message = exception

finally:
print "ok #"
say message
.end

.namespace ['Parent']

.sub 'init' :vtable
die 'test exception from init vtable'
.end

Originally opened as  http://rt.perl.org/rt3/Ticket/Display.html?id=38432

Change History

Changed 5 years ago by coke

TODO test added to t/oo/new-old.t in r42148.

Changed 5 years ago by NotFound

Use unroll:

.sub main :main
.local pmc type
newclass type, 'Parent'

.local pmc obj, exception
.local string message
message = 'no error'
push_eh handler
obj = new 'Parent'
print 'not '
pop_eh
goto finally

handler:
.get_results(exception)
unroll exception
pop_eh
message = exception

finally:
print "ok #"
say message
.end

.namespace ['Parent']

.sub 'init' :vtable
die 'test exception from init vtable'
.end

See TT #1635

Changed 4 years ago by NotFound

The unroll opcode has been renamed to finalize, here is the snippet updated:

.sub main :main
.local pmc type
newclass type, 'Parent'

.local pmc obj, exception
.local string message
message = 'no error'
push_eh handler
obj = new 'Parent'
print 'not '
pop_eh
goto finally

handler:
.get_results(exception)
finalize exception
pop_eh
message = exception

finally:
print "ok #"
say message
.end

.namespace ['Parent']

.sub 'init' :vtable
die 'test exception from init vtable'
.end

I think the ticket must remain open until finalize goes out of experimental stage and becomes part of the recommended way of handling exceptions.

Changed 4 years ago by whiteknight

  • status changed from new to closed
  • resolution set to duplicate

This is a duplicate of #833. I am closing this ticket.

Changed 4 years ago by whiteknight

  • status changed from closed to reopened
  • resolution duplicate deleted
The underlying bug for both issues is the same, and the solution is the same.

--Andrew Whitworth



On Mon, Nov 22, 2010 at 8:06 AM, Will Coleda <will@coleda.com> wrote:
> Not exactly. One is using a :vtable, one is not.
> _______________________________________________
> parrot-tickets mailing list
> parrot-tickets@lists.parrot.org
> http://lists.parrot.org/mailman/listinfo/parrot-tickets
>

Changed 4 years ago by whiteknight

  • status changed from reopened to closed
  • resolution set to duplicate

Changed 3 years ago by NotFound

Test fixed by using finalize in 43ba0b079b

Like the other problems related with exceptions thrown from inner loops, this is not a full solution to the issues, uncaught exceptions still can lead to segfaults. But as long as the purpose of the test is the ability to handle exceptions from object construction, the ticket can be kept closed.

Note: See TracTickets for help on using tickets.