Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B::Deparse fails with utf8 and our #7744

Closed
p5pRT opened this issue Jan 10, 2005 · 8 comments
Closed

B::Deparse fails with utf8 and our #7744

p5pRT opened this issue Jan 10, 2005 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 10, 2005

Migrated from rt.perl.org#33752 (status was 'resolved')

Searchable as RT33752$

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2005

From @nwc10

Created by @nwc10

./perl -Ilib -MO=Deparse born
While deparsing born near line 3,
Unexpected our($人)
CHECK failed--call queue aborted.

born is one of the examples from t/run/freshperl.t

use strict;
use utf8;
our $人 = 2; # 0xe4 0xba 0xba​: U+4eba, "human" in CJK ideograph
$人++; # a child is born
print $人, "\n";

I assume that Deparse should be able to handle it.

Nicholas Clark

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.9.2:

Configured by nick at Mon Jan 10 20:06:31 GMT 2005.

Summary of my perl5 (revision 5 version 9 subversion 2 patch 22511) configuration:
  Platform:
    osname=freebsd, osvers=5.3-release-p2, archname=i386-freebsd-thread-multi
    uname='freebsd saigo.etla.org 5.3-release-p2 freebsd 5.3-release-p2 #1: wed dec 15 21:05:13 gmt 2004 root@saigo.etla.org:usrobjusrsrcsyssaigo i386 '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list=  -Dinc_version_list_init=0 -Doptimize=-O2 -g -Accccflags=-DPERL_COPY_ON_WRITE -Dusethreads -Uuse64bitint -Uusemymalloc -Dprefix=~/Sandpit/snap5.9.x-23780 -Dinstallman1dir=none -Dinstallman3dir=none -Duseperlio -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include',
    optimize='-O2 -g',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.4.2 [FreeBSD] 20040728', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil -lc_r
    perllibs=-lm -lcrypt -lutil -lc_r
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    DEVEL22511


@INC for perl v5.9.2:
    lib
    /home/nick/Sandpit/snap5.9.x-23780/lib/perl5/5.9.2/i386-freebsd-thread-multi
    /home/nick/Sandpit/snap5.9.x-23780/lib/perl5/5.9.2
    /home/nick/Sandpit/snap5.9.x-23780/lib/perl5/site_perl/5.9.2/i386-freebsd-thread-multi
    /home/nick/Sandpit/snap5.9.x-23780/lib/perl5/site_perl/5.9.2
    /home/nick/Sandpit/snap5.9.x-23780/lib/perl5/site_perl
    .


Environment for perl v5.9.2:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/nick/bin:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2010

From @cpansprout

On Mon Jan 10 14​:59​:13 2005, nicholas wrote​:

./perl -Ilib -MO=Deparse born
While deparsing born near line 3,
Unexpected our($人)
CHECK failed--call queue aborted.

born is one of the examples from t/run/freshperl.t

use strict;
use utf8;
our $人 = 2; # 0xe4 0xba 0xba​: U+4eba, "human" in CJK ideograph
$人++; # a child is born
print $人, "\n";

The attached patch fixes this.

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2010

From @cpansprout

Inline Patch
diff -Nurp blead-33752-unideparse.base/dist/B-Deparse/Deparse.pm blead-33752-unideparse/dist/B-Deparse/Deparse.pm
--- blead-33752-unideparse.base/dist/B-Deparse/Deparse.pm	2010-09-20 22:06:11.000000000 -0700
+++ blead-33752-unideparse/dist/B-Deparse/Deparse.pm	2010-10-16 10:01:58.000000000 -0700
@@ -1041,9 +1041,11 @@ sub maybe_local {
 	and not $self->{'avoid_local'}{$$op}) {
 	my $our_local = ($op->private & OPpLVAL_INTRO) ? "local" : "our";
 	if( $our_local eq 'our' ) {
-	    # XXX This assertion fails code with non-ASCII identifiers,
-	    # like ./ext/Encode/t/jperl.t
-	    die "Unexpected our($text)\n" unless $text =~ /^\W(\w+::)*\w+\z/;
+	    if ( $text !~ /^\W(\w+::)*\w+\z/
+	     and !utf8::decode($text) || $text !~ /^\W(\w+::)*\w+\z/
+	    ) {
+		die "Unexpected our($text)\n";
+	    }
 	    $text =~ s/(\w+::)+//;
 	}
         if (want_scalar($op)) {
diff -Nurp blead-33752-unideparse.base/dist/B-Deparse/t/deparse.t blead-33752-unideparse/dist/B-Deparse/t/deparse.t
--- blead-33752-unideparse.base/dist/B-Deparse/t/deparse.t	2010-09-20 22:06:11.000000000 -0700
+++ blead-33752-unideparse/dist/B-Deparse/t/deparse.t	2010-10-16 16:48:47.000000000 -0700
@@ -17,7 +17,7 @@ BEGIN {
     require feature;
     feature->import(':5.10');
 }
-use Test::More tests => 90;
+use Test::More tests => 91;
 use Config ();
 
 use B::Deparse;
@@ -166,6 +166,19 @@ eval <<EOFCODE and test($x);
    1
 EOFCODE
 
+# [perl #33752]
+{
+  my $code = <<"EOCODE";
+{
+    our \$\x{1e1f}\x{14d}\x{14d};
+}
+EOCODE
+  my $deparsed
+   = $deparse->coderef2text(eval "sub { our \$\x{1e1f}\x{14d}\x{14d} }" );
+  s/$ \n//x for $deparsed, $code;
+  is $deparsed, $code, 'our $funny_Unicode_chars';
+}
+
 __DATA__
 # 2
 1;

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2010

From [Unknown Contact. See original ticket]

On Mon Jan 10 14​:59​:13 2005, nicholas wrote​:

./perl -Ilib -MO=Deparse born
While deparsing born near line 3,
Unexpected our($人)
CHECK failed--call queue aborted.

born is one of the examples from t/run/freshperl.t

use strict;
use utf8;
our $人 = 2; # 0xe4 0xba 0xba​: U+4eba, "human" in CJK ideograph
$人++; # a child is born
print $人, "\n";

The attached patch fixes this.

@p5pRT
Copy link
Author

p5pRT commented Oct 17, 2010

@cpansprout - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From @cpansprout

On Sun Oct 17 13​:09​:33 2010, sprout wrote​:

On Mon Jan 10 14​:59​:13 2005, nicholas wrote​:

./perl -Ilib -MO=Deparse born
While deparsing born near line 3,
Unexpected our($人)
CHECK failed--call queue aborted.

born is one of the examples from t/run/freshperl.t

use strict;
use utf8;
our $人 = 2; # 0xe4 0xba 0xba​: U+4eba, "human" in CJK ideograph
$人++; # a child is born
print $人, "\n";

The attached patch fixes this.

Applied as 640d5d4.

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From [Unknown Contact. See original ticket]

On Sun Oct 17 13​:09​:33 2010, sprout wrote​:

On Mon Jan 10 14​:59​:13 2005, nicholas wrote​:

./perl -Ilib -MO=Deparse born
While deparsing born near line 3,
Unexpected our($人)
CHECK failed--call queue aborted.

born is one of the examples from t/run/freshperl.t

use strict;
use utf8;
our $人 = 2; # 0xe4 0xba 0xba​: U+4eba, "human" in CJK ideograph
$人++; # a child is born
print $人, "\n";

The attached patch fixes this.

Applied as 640d5d4.

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

@cpansprout - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant