Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add an exception handler around check for can __dump. #239

Closed
wants to merge 1 commit into from

3 participants

@KrisShannon

The 6model internals throw an exception here in some
circumstances stopping the nqp --target=past dumping
from working.

@KrisShannon KrisShannon Add an exception handler around check for can __dump.
The 6model internals throw an exception here in some
circumstances stopping the nqp --target=past dumping
from working.
2a5a35f
@leto
Owner

Can you add a test or give an example of NQP that triggers this code?

@KrisShannon

With the nqp from git://github.com/perl6/nqp.git running:

nqp --target=past -e 1

dies attempting to dump the EXPORTHOW PMC with:

No method cache and no find_method method in meta-object
current instr.: 'parrot;Data;Dumper;Default;pmcDefault' pc 242 (runtime/parrot/library/Data/Dumper/Default.pir:203)
called from Sub 'parrot;Data;Dumper;Base;dump' pc 383 (runtime/parrot/library/Data/Dumper/Base.pir:251)
called from Sub 'parrot;Data;Dumper;Default;dumpWithName' pc 40 (runtime/parrot/library/Data/Dumper/Default.pir:56)
called from Sub 'parrot;Data;Dumper;Default;genericHash' pc 184 (runtime/parrot/library/Data/Dumper/Default.pir:153)
called from Sub 'parrot;Data;Dumper;Base;dump' pc 383 (runtime/parrot/library/Data/Dumper/Base.pir:251)
called from Sub 'parrot;Data;Dumper;Default;dumpWithName' pc 40 (runtime/parrot/library/Data/Dumper/Default.pir:56)
called from Sub 'parrot;Data;Dumper;Default;genericHash' pc 184 (runtime/parrot/library/Data/Dumper/Default.pir:153)
called from Sub 'parrot;Data;Dumper;Base;dump' pc 383 (runtime/parrot/library/Data/Dumper/Base.pir:251)
called from Sub 'parrot;Capture;__dump' pc 600 (runtime/parrot/library/Data/Dumper/Default.pir:454)
called from Sub 'parrot;Data;Dumper;Default;pmcDefault' pc 261 (runtime/parrot/library/Data/Dumper/Default.pir:208)
called from Sub 'parrot;Data;Dumper;Base;dump' pc 383 (runtime/parrot/library/Data/Dumper/Base.pir:251)
called from Sub 'parrot;Data;Dumper;Default;dumpWithName' pc 40 (runtime/parrot/library/Data/Dumper/Default.pir:56)
called from Sub 'parrot;Data;Dumper;dumper' pc 70 (runtime/parrot/library/Data/Dumper.pir:43)
called from Sub '_dumper' pc 56 (runtime/parrot/library/dumper.pir:89)
called from Sub 'nqp;HLL;Compiler;dumper' pc 38449 (src/stage2/gen/NQPHLL.pir:14059) (src/stage2/gen/NQPHLL.pm:1540)
called from Sub 'nqp;HLL;Compiler;_block1864' pc 35540 (src/stage2/gen/NQPHLL.pir:12596) (src/stage2/gen/NQPHLL.pm:1386)
called from Sub 'nqp;HLL;Compiler;command_eval' pc 34969 (src/stage2/gen/NQPHLL.pir:12356) (src/stage2/gen/NQPHLL.pm:1401)
called from Sub 'nqp;HLL;Compiler;command_line' pc 34633 (src/stage2/gen/NQPHLL.pir:12198) (src/stage2/gen/NQPHLL.pm:1353)
called from Sub 'MAIN' pc 14443 (src/stage2/gen/NQP.pir:3026) (src/stage2/gen/NQP.pm:2839)
called from Sub '_block1000' pc 196 (src/stage2/gen/NQP.pir:104) (src/stage2/gen/NQP.pm:1)
@leto
Owner

Just as a datapoint, "parrot-nqp --target=past -e 1" works fine as of parrot RELEASE_3_11_0-5-g2006557 .

@KrisShannon : Which SHA1 of nqp.git did this happen to you on?

Also, "No method cache and no find_method method in meta-object" sounds like a deeper problem, although I agree that nqp should not fail like this. Perhaps @moritz knows what is going on?

@KrisShannon

tag 2011.12 of nqp.git

Also current rakudo nom "perl6 --target=past -e 1" is dying with:

use of uninitialized value of type Mu in string context
use of uninitialized value of type Mu in string context
use of uninitialized value of type Mu in string context
use of uninitialized value of type Mu in string context
===SORRY!===
Method '__dump' not found for invocant of class 'Any'

I'm trying to instrument it further to track it down.

@KrisShannon

OK, The find_method in sixmodel seems to throw exceptions rather than return nulls for missing methods.

I guess that the real fix would be a custom 'can' VTABLE method which traps exceptions and returns false.

Unfortunately that's a bit beyond me at the moment. Not sure how to catch exceptions from a C function.

@KrisShannon

I've made a patch to perl6/nqp#25 to add a specialized can VTABLE for sixmodel objects.

I still think something here is a good idea, possibly something which catches exceptions thrown during the __dump call as well - maybe dumping the exception as best as possible and then continuing.

You use a dumper like this when your doing some kind of debugging and the general murphy's rule with debugging is the missing information is the bit you need to track down the bug :)

@KrisShannon KrisShannon referenced this pull request in perl6/nqp
Merged

Catch exceptions in VTABLE find_method #25

@leto
Owner

I agree with @KrisShannon in that we should have guards here, "just in case", but I wanted to make sure the deeper problems were also being fixed.

I am unsure exactly how to test this pull request. Does it depend on perl6/nqp#25 ? Which branch/commit of Rakudo ?

@KrisShannon

I'm thinking I will improve this to catch exceptions from both the can "__dump", and the actual method call itself and dump appropriate error text to show that it caught an exception.

I'll add some tests as well to demonstrate it in action.

@leto
Owner

+1

@leto
Owner

@KrisShannon any progress on this?

@zhuomingliang
Collaborator

Closed, because nqp --target=ast -e 1 works well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2011
  1. @KrisShannon

    Add an exception handler around check for can __dump.

    KrisShannon authored
    The 6model internals throw an exception here in some
    circumstances stopping the nqp --target=past dumping
    from working.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 runtime/parrot/library/Data/Dumper/Default.pir
View
4 runtime/parrot/library/Data/Dumper/Default.pir
@@ -200,11 +200,15 @@ Escape any characters in a string so we can re-use it as a literal.
print type
print "' "
+ push_eh CATCH
$I0 = can dump, "__dump"
if $I0 goto CAN_DUMP
+CATCH:
+ pop_eh
print "{ ... }"
branch END
CAN_DUMP:
+ pop_eh
dump."__dump"( self, name )
END:
.return ( 1 )
Something went wrong with that request. Please try again.