Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Catch exceptions in VTABLE find_method #25

Merged
merged 2 commits into from

1 participant

@KrisShannon
Collaborator

I need this to get 'nqp --target=past -e 1' working again.

@KrisShannon
Collaborator

This came from dukeleto++ wanting to find the real cause I was just patching over in parrot/parrot#239

@KrisShannon KrisShannon Catch exceptions in VTABLE find_method
The sixmodel VTABLE find_method calls the find_method
in the containers STABLE which will throw instead of
returning NULL if it can't find the method.

Anything which is calling the VTABLE find_method is not
going to be expecting an exception so catch any exception
and return NULL.
390af1f
@KrisShannon
Collaborator

UPDATED:

Dropped the new VTABLE can,
and moved the exception catching into VTABLE find_method

sorear++ pointed out that exceptions shouldn't be being thrown
from VTABLE find_method at all.

@KrisShannon
Collaborator

Hmm, it looks like this isn't good enough as an exception handler. I'm geting segfault's when I've intercepted an exception
and returned NULL to another C routine which sees the NULL and throw's it's own exception.

@KrisShannon KrisShannon merged commit b9c26af into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 1, 2012
  1. @KrisShannon

    Catch exceptions in VTABLE find_method

    KrisShannon authored
    The sixmodel VTABLE find_method calls the find_method
    in the containers STABLE which will throw instead of
    returning NULL if it can't find the method.
    
    Anything which is calling the VTABLE find_method is not
    going to be expecting an exception so catch any exception
    and return NULL.
Commits on Jan 2, 2012
  1. @KrisShannon
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 2 deletions.
  1. +25 −2 src/pmc/sixmodelobject.pmc
View
27 src/pmc/sixmodelobject.pmc
@@ -22,6 +22,8 @@
* out (since that depends on the representation).
*/
+#include "parrot/exceptions.h"
+#include "parrot/events.h"
#include "../6model/sixmodelobject.h"
/* We need to know how to boolify bigints. Really need something better,
@@ -94,8 +96,29 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
}
VTABLE PMC * find_method(STRING *name) {
- PMC *decont = decontainerize(interp, SELF);
- return STABLE(decont)->find_method(interp, decont, name, NO_HINT);
+ PMC *m = PMCNULL;
+ PMC *decont;
+ Parrot_runloop jmp;
+ Parrot_Context *initialctx;
+ int runloop_id;
+
+ initialctx = CONTEXT(interp);
+ runloop_id = interp->current_runloop_id;
+ if (!setjmp(jmp.resume)) {
+ Parrot_ex_add_c_handler(interp, &jmp);
+ /* try */
+ decont = decontainerize(interp, SELF);
+ m = STABLE(decont)->find_method(interp, decont, name, NO_HINT);
+ } else {
+ while (interp->current_runloop && interp->current_runloop_id != runloop_id)
+ free_runloop_jump_point(interp);
+ if (initialctx != CONTEXT(interp))
+ Parrot_warn((interp), PARROT_WARNINGS_ALL_FLAG,
+ "find_method contexts differ!");
+ }
+ Parrot_cx_delete_handler_local(interp);
+
+ return m;
}
VTABLE PMC* get_attr_keyed(PMC *class_handle, STRING *name) {
Something went wrong with that request. Please try again.