Skip Menu |
 

This queue is for tickets about the JSPL CPAN distribution.

Report information
The Basics
Id: 74602
Status: patched
Priority: 0/
Queue: JSPL

People
Owner: sog [...] msg.com.mx
Requestors: robb [...] canfield.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



From robb [...] canfield.com Wed Feb 1 18: 00:28 2012
MIME-Version: 1.0
X-Spam-Status: No, score=-1.9 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9] autolearn=ham
X-Spam-Flag: NO
content-type: text/plain; charset="utf-8"; format="flowed"
Message-ID: <4F29C402.1060102 [...] canfield.com>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -1.9
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id F40A9241698 for <cpan-bug+JSPL [...] hipster.bestpractical.com>; Wed, 1 Feb 2012 18:00:27 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 79utbQtjVid4 for <cpan-bug+JSPL [...] hipster.bestpractical.com>; Wed, 1 Feb 2012 18:00:26 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 27D06241683 for <bug-JSPL [...] rt.cpan.org>; Wed, 1 Feb 2012 18:00:25 -0500 (EST)
Received: (qmail 3262 invoked by uid 103); 1 Feb 2012 23:00:25 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 1 Feb 2012 23:00:25 -0000
Received: from mail.canfield.com (HELO mx-chicago.canfield.com) (208.100.7.129) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Wed, 01 Feb 2012 15:00:22 -0800
Received: from [10.1.0.98] (c-76-104-168-14.hsd1.wa.comcast.net [76.104.168.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: robb [...] canfield.com) by mx-chicago.canfield.com (Postfix) with ESMTP id 3BD7BEC079D for <bug-JSPL [...] rt.cpan.org>; Wed, 1 Feb 2012 15:00:19 -0800 (PST)
Delivered-To: cpan-bug+JSPL [...] hipster.bestpractical.com
Subject: Silent JS crash changing a key in a TIED hash
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16
Return-Path: <robb [...] canfield.com>
X-RT-Mail-Extension: jspl
X-Original-To: cpan-bug+JSPL [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Wed, 01 Feb 2012 15:00:18 -0800
X-Spam-Level:
To: bug-JSPL [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: robb <robb [...] canfield.com>
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 3172
Thanks for coding JSPL, I was using JavaScript::MonkeyScript but it lacked a reliable way to alter data. JSPL allows a lot more flexibility. Unfortunately I am encountering a problem. The following code tests some assumptions I have about JSPL. Everything works until the end of the JS code. When I try to change a TIED Perl HASH the JS exits. An exception is not thrown. A normal HASH can be modified easily. Is there something I am doing wrong? # Example of silent JS crash setting a TIED variable use JSPL; use strict; my $ctx = JSPL::Runtime->new->create_context(); $ctx->bind_function( out => sub {print @_, "\n";}, ); $ctx->bind_function( array_test => sub {return [qw/a b c d/];} ); $ctx->bind_function( hash_test => sub {return {'a' => 'A', 'b' => 'B', 'c' => {'c1' => 'C1', 'c2' => 'C2'}};} ); my %Data; tie(%Data, 'Data::Hash', {'Name' => 'Robb', 'Address' => 'this is address', 'State' => 'this is state'}); use Data::Dumper; warn(Dumper(\%Data)); $ctx->bind_value('Data.Query' => \%Data); my $result = $ctx->eval(<<'{END}'); // Core Array Works var a = array_test(); out(a[2]); a[2] = 'Changed array a[2]'; out(a[2]); // Core HASH works var b = hash_test(); out(b.a); var i; for (i in b.c) { out(i + " : " + b.c[i]); } b.b = 'Changed hash b.b'; out(b.b); // Reading tied hash works out(Data.Query.Name); // ******* Writing tied hash FAILS silently at the set Data.Query.Name = 'Robb^Canfield'; out(Data.Query.Name); {END} warn(Dumper($result)); # Test of tie package for Data HASH package Data::Hash; use Storable qw/dclone/; our @ISA = 'Tie::StdHash'; sub TIEHASH { my $class = shift; my( $data, $ro, ) = @_; my $self = { 'ro' => $ro || 0, 'data' => dclone($data), }; if (0 && ! $ro) { $self->{'original'} => {}; tie(%{$self->{'original'}}, __PACKAGE__, dclone($data), 1); } return bless $self, $class; } sub STORE { print STDERR "STORE\n"; my $self = shift; my( $key, $value, ) = @_; if (! $self->{'ro'}) { $self->{'data'}{$key} = $value; } return $self->{'data'}{$key}; } sub FETCH { print STDERR "FETCH\n"; my $self = shift; my( $key, ) = @_; return $self->{'data'}{$key}; } # DELETE is NOT supported! Removing data elements is not currently supported as its a bit of a pain to deal with what can and cannot be removed sub DELETE { my $self = shift; my( $key, ) = @_; } # CLEAR is NOT supported! See DELETE for why sub CLEAR { my $self = shift; } sub EXISTS { print STDERR "EXISTS\n"; my $self = shift; my( $key, ) = @_; return exists $self->{'data'}{$key}; } sub FIRSTKEY { print STDERR "FIRSTKEY\n"; my $self = shift; # Use native Perl HASH tracking on the data hash my $a = keys %{$self->{'data'}}; # reset internal each() iterator return each %{$self->{'data'}}; } sub NEXTKEY { print STDERR "NEXTKEY\n"; my $self = shift; return each %{$self->{'data'}}; } sub SCALAR { print STDERR "SCALAR\n"; my $self = shift; return scalar(%{$self->{'data'}}); }
MIME-Version: 1.0
In-Reply-To: <4F29C402.1060102 [...] canfield.com>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <4F29C402.1060102 [...] canfield.com>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-17369-1328169049-235.74602-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 434
Download (untitled) / with headers
text/plain 434b
Robb, Thanks for your bug report. Can you test with following patch applied? ====== CUT ======= --- PJS_PerlHash.c (revision 3103) +++ PJS_PerlHash.c (working copy) @@ -89,7 +89,7 @@ svk = PJS_JSString2SV(aTHX_ cx, PJSID_TO(STRING, id)); if(!hv_store_ent(hv, svk, sv, 0)) { - if(SvSMAGICAL(hv)) mg_set(sv); + if(SvSMAGICAL(sv)) mg_set(sv); else ok = JS_FALSE; // TODO: Check error to report } sv_free(svk);
From robb [...] canfield.com Thu Feb 2 10: 24:42 2012
MIME-Version: 1.0
X-Spam-Status: No, score=-1.9 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-17369-1328169049-1711.74602-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-74602 [...] rt.cpan.org> <4F29C402.1060102 [...] canfield.com> <rt-3.8.HEAD-17369-1328169049-1711.74602-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4F2AAAB2.8010209 [...] canfield.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
X-Spam-Score: -1.9
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id CF1AD241572 for <cpan-bug+JSPL [...] hipster.bestpractical.com>; Thu, 2 Feb 2012 10:24:42 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F9OnjoG2Hyd3 for <cpan-bug+JSPL [...] hipster.bestpractical.com>; Thu, 2 Feb 2012 10:24:41 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 8D6F92412A8 for <bug-JSPL [...] rt.cpan.org>; Thu, 2 Feb 2012 10:24:41 -0500 (EST)
Received: (qmail 21826 invoked by uid 103); 2 Feb 2012 15:24:40 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 2 Feb 2012 15:24:40 -0000
Received: from mail.canfield.com (HELO mx-chicago.canfield.com) (208.100.7.129) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Thu, 02 Feb 2012 07:24:38 -0800
Received: from [10.1.0.98] (c-76-104-168-14.hsd1.wa.comcast.net [76.104.168.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: robb [...] canfield.com) by mx-chicago.canfield.com (Postfix) with ESMTP id 8156BEC079D for <bug-JSPL [...] rt.cpan.org>; Thu, 2 Feb 2012 07:24:35 -0800 (PST)
Delivered-To: cpan-bug+JSPL [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16
Subject: Re: [rt.cpan.org #74602] Silent JS crash changing a key in a TIED hash
Return-Path: <robb [...] canfield.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+JSPL [...] hipster.bestpractical.com
X-RT-Mail-Extension: jspl
Date: Thu, 02 Feb 2012 07:24:34 -0800
X-Spam-Level:
To: bug-JSPL [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: robb <robb [...] canfield.com>
RT-Message-ID: <rt-3.8.HEAD-17367-1328196283-558.74602-0-0 [...] rt.cpan.org>
Content-Length: 496
Download (untitled) / with headers
text/plain 496b
The patch applied and worked perfectly. My test now passes. Thank you very much. On 02/01/2012 11:50 PM, Salvador Ortiz via RT wrote: Show quoted text
> --- PJS_PerlHash.c (revision 3103) > +++ PJS_PerlHash.c (working copy) > @@ -89,7 +89,7 @@ > svk = PJS_JSString2SV(aTHX_ cx, PJSID_TO(STRING, id)); > > if(!hv_store_ent(hv, svk, sv, 0)) { > - if(SvSMAGICAL(hv)) mg_set(sv); > + if(SvSMAGICAL(sv)) mg_set(sv); > else ok = JS_FALSE; // TODO: Check error to report > } > sv_free(svk);


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.