Skip to content
This repository

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

Closed
wants to merge 1 commit into from

3 participants

Kris Shannon Duke Leto Jimmy Zhuo
Kris Shannon

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

Kris Shannon 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
Duke Leto
Owner

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

Kris Shannon

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)
Duke 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?

Kris Shannon

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.

Kris Shannon

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.

Kris Shannon

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 :)

Duke 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 ?

Kris Shannon

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.

Duke Leto
Owner

+1

Duke Leto
Owner

@KrisShannon any progress on this?

Jimmy Zhuo
Collaborator

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

Jimmy Zhuo zhuomingliang closed this March 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 31, 2011
Kris Shannon 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
This page is out of date. Refresh to see the latest.
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.
200 200
     print type
201 201
     print "' "
202 202
 
  203
+    push_eh CATCH
203 204
     $I0 = can dump, "__dump"
204 205
     if $I0 goto CAN_DUMP
  206
+CATCH:
  207
+    pop_eh
205 208
     print "{ ... }"
206 209
     branch END
207 210
 CAN_DUMP:
  211
+    pop_eh
208 212
     dump."__dump"( self, name )
209 213
 END:
210 214
     .return ( 1 )
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.