Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: CGI::Session cannot read data from Data::Dumper

by !1 (Hermit)
on Oct 31, 2007 at 22:05 UTC ( [id://648380]=note: print w/replies, xml ) Need Help??


in reply to CGI::Session cannot read data from Data::Dumper

Basically the problem is that Safe creates a new environment and the class into which your data has been blessed is not the same class that exists in our normal environment.

use Safe; use Devel::Peek; my $r = 'bless \\ do { my $x = 0 }, "x"'; print Dump(eval $r); print Dump(Safe->new->reval($r)); print Dump(eval $r); print Dump(Safe->new->reval($r));

Which outputs (on my machine at least):

SV = RV(0x1847158) at 0x1830630 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x182fa48 SV = PVMG(0x18a9974) at 0x182fa48 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x18d8620 "x" SV = RV(0x1847188) at 0x18d8b24 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x18d8b00 SV = PVMG(0x18a8f34) at 0x18d8b00 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x18d8b54 "x" SV = RV(0x1847180) at 0x18d88fc REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x18d8920 SV = PVMG(0x18a90f4) at 0x18d8920 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x18d8620 "x" SV = RV(0x1847188) at 0x18d8b18 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x18d8a28 SV = PVMG(0x18a90f4) at 0x18d8a28 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x18d8b90 "x"

Notice how the stash has the same address for both the first and third runs. The second and fourth entries (those that are both from new Safe environments) have stashes where the address does not match either. This is because the x namespace in our environment is not the same as the one in either of the Safe compartments we created. I'm curious which version of CGI::Session you are using since I submitted a crummy fix that walks the structure and reblesses everything in place in the 4.x version (__walk in CGI::Session::Serialize::default).

Replies are listed 'Best First'.
Re^2: CGI::Session cannot read data from Data::Dumper
by lom (Sexton) on Nov 01, 2007 at 11:27 UTC

    Thanks a lot for this explanation.

    I'm using the Debian testing CGI::Session (4.20):

    # $Id: Session.pm 353 2006-12-05 02:10:19Z markstos $
    $CGI::Session::VERSION = '4.20';

    __xwalk is definitely present.

      If you don't mind, could you tell me what this returns?

      use Safe; use Devel::Peek; my $x = bless \ do { my $a = 0 }, "x"; print Dump($x); my $y = Safe->new->reval('bless \\ do { my $a = 0 }, "x"'); print Dump($y); bless $y, ref $y; print Dump($y);
        here you are:
        SV = RV(0x81786c0) at 0x8151690 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x815163c SV = PVMG(0x81d1948) at 0x815163c REFCNT = 2 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x8150b44 "x" SV = RV(0x81786f4) at 0x8151624 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x81fbd04 SV = PVMG(0x81d1b28) at 0x81fbd04 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x81fbd58 "x" SV = RV(0x81786f4) at 0x8151624 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x81fbd04 SV = PVMG(0x81d1b28) at 0x81fbd04 REFCNT = 1 FLAGS = (PADBUSY,PADMY,OBJECT,IOK,pIOK) IV = 0 NV = 0 PV = 0 STASH = 0x8150b44 "x"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://648380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found