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

Bleadperl v5.19.1-480-g9baac1a breaks COWENS/autobox-dump-20090426.1746.tar.gz, APLA/Project-Easy-0.30.tar.gz #13113

Closed
p5pRT opened this issue Jul 19, 2013 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 19, 2013

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

Searchable as RT118933$

@p5pRT
Copy link
Author

p5pRT commented Jul 19, 2013

From @andk

git bisect


commit 9baac1a
Author​: Slaven Rezic <srezic@​iconmobile.com>
Date​: Wed Jul 10 14​:18​:18 2013 +1000

  Data​::Dumper​: useqq implementation for xs

diagnostics


http​://www.cpantesters.org/cpan/report/9054ada6-eefd-11e2-8c2c-94abf1ff63fb

No new enough reports yet available on cpantesters for autobox-dump.

perl -V


Summary of my perl5 (revision 5 version 19 subversion 2) configuration​:
  Commit id​: 9baac1a
  Platform​:
  osname=linux, osvers=3.9-1-amd64,
  archname=x86_64-linux-thread-multi-ld
  uname='linux k83 3.9-1-amd64 #1 smp debian 3.9.8-1 x86_64 gnulinux '
  config_args='-Dprefix=/home/sand/src/perl/repoperls/installed-perls/perl/v5.19.1-480-g9baac1a/a2da
  -Dmyhostname=k83 -Dinstallusrbinperl=n -Uversiononly -Dusedevel -des
  -Ui_db -Duseithreads -Duselongdouble -DDEBUGGING=-g'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=define
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
  -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
  -D_FILE_OFFSET_BITS=64',
  optimize='-O2 -g',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
  -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.8.1', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='long double', nvsize=16,
  Off_t='off_t', lseeksize=8
  alignbytes=16, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib
  /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
  -lgdbm_compat
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  libc=, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.17'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib
  -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
  PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
  PERL_USE_DEVEL USE_64_BIT_ALL USE_64_BIT_INT
  USE_ITHREADS USE_LARGE_FILES USE_LOCALE
  USE_LOCALE_COLLATE USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC USE_LONG_DOUBLE USE_PERLIO
  USE_PERL_ATOF USE_REENTRANT_API
  Built under linux
  Compiled at Jul 19 2013 04​:32​:06
  @​INC​:
  /home/sand/src/perl/repoperls/installed-perls/perl/v5.19.1-480-g9baac1a/a2da/lib/site_perl/5.19.2/x86_64-linux-thread-multi-ld
  /home/sand/src/perl/repoperls/installed-perls/perl/v5.19.1-480-g9baac1a/a2da/lib/site_perl/5.19.2
  /home/sand/src/perl/repoperls/installed-perls/perl/v5.19.1-480-g9baac1a/a2da/lib/5.19.2/x86_64-linux-thread-multi-ld
  /home/sand/src/perl/repoperls/installed-perls/perl/v5.19.1-480-g9baac1a/a2da/lib/5.19.2
  .

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

On Fri Jul 19 02​:50​:51 2013, andreas.koenig.7os6VVqR@​franz.ak.mind.de wrote​:

git bisect
----------
commit 9baac1a
Author​: Slaven Rezic <srezic@​iconmobile.com>
Date​: Wed Jul 10 14​:18​:18 2013 +1000

Data&#8203;::Dumper&#8203;: useqq implementation for xs

diagnostics
-----------
http​://www.cpantesters.org/cpan/report/9054ada6-eefd-11e2-8c2c-
94abf1ff63fb

The failure in Project​::Easy is from it fiddling directly with the
internals of Data​::Dumper.

Project​::Easy​::Config​::Format​::perl contains the code​:

{
  no warnings 'redefine';
  sub Data​::Dumper​::qquote {
  my $s = shift;
  return "'$s'";
  }
}

and then forces Useqq later to try to force the perl Dump() to be used.

Since the XS dumper doesn't call sub qquote() the replacement doesn't occur.

autobox-dump looks like a different problem.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

On Sun Jul 21 18​:28​:32 2013, tonyc wrote​:

autobox-dump looks like a different problem.

Which it is.

The pure-perl dumper (with or without useqq) outputs SVs which can be
represented as small(-ish) decimal numbers *as* numbers, but the new
useqq handling didn't.

The XS non-useqq code however doesn't do this. rather than probably
breaking many more CPAN tests by making them consistent I'm adding code
that does the same check as the pure perl code does, but enabling it
only for useqq.

The attached patch, which I'll apply post 5.19.2 (and probably with a
version bump) allows autobox​::dump to pass.

I don't plan on any changes to support Project​::Easy, that's purely a
bug in that module.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

On Sun Jul 21 22​:31​:54 2013, tonyc wrote​:

The attached patch, which I'll apply post 5.19.2 (and probably with a
version bump) allows autobox​::dump to pass.

Now with more attachment.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

0001-perl-74798-improved-useqq-compatibility-with-the-pur.patch
From f8e039f96e269609b4b496ca3fc8f15b1ea8c393 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 22 Jul 2013 14:59:57 +1000
Subject: [PATCH] [perl #74798] improved useqq compatibility with the pure
 perl version

Currently for non-useqq, the pure perl and XS output for numbers like
these is different, but XS useqq is new, so try to remain vaguely
compatible.
---
 dist/Data-Dumper/Dumper.xs  |   45 +++++++++++++++++++++++++++++++++++++++++++
 dist/Data-Dumper/t/dumper.t |   21 ++++++++++++++++++--
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs
index 0194a2c..3bcb2f4 100644
--- a/dist/Data-Dumper/Dumper.xs
+++ b/dist/Data-Dumper/Dumper.xs
@@ -119,6 +119,42 @@ TOP:
     return 0;
 }
 
+/* Check that the SV can be represented as a simple decimal integer.
+ *
+ * The perl code does this by matching against /^(?:0|-?[1-9]\d{0,8})\z/
+*/
+static I32
+safe_decimal_number(SV *val) {
+    STRLEN len;
+    const char *p = SvPV(val, len);
+
+    if (len == 1 && *p == '0')
+        return TRUE;
+
+    if (len && *p == '-') {
+        ++p;
+        --len;
+    }
+
+    if (len == 0 || *p < '1' || *p > '9')
+        return FALSE;
+
+    ++p;
+    --len;
+
+    if (len > 8)
+        return FALSE;
+
+    while (len > 0) {
+         /* the perl code checks /\d/ but we don't want unicode digits here */
+         if (*p < '0' || *p > '9')
+             return FALSE;
+         ++p;
+         --len;
+    }
+    return TRUE;
+}
+
 /* count the number of "'"s and "\"s in string */
 static I32
 num_q(const char *s, STRLEN slen)
@@ -1115,6 +1151,15 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
 	    sv_catpvn(retval, (const char *)mg->mg_ptr, mg->mg_len);
 	}
 #endif
+
+	/* the pure perl and XS non-qq outputs have historically been
+	 * different in this case, but for useqq, let's try to match
+	 * the pure perl code.
+	 * see [perl #74798]
+	 */
+	else if (useqq && safe_decimal_number(val)) {
+	    sv_catsv(retval, val);
+	}
 	else {
         integer_came_from_string:
 	    c = SvPV(val, i);
diff --git a/dist/Data-Dumper/t/dumper.t b/dist/Data-Dumper/t/dumper.t
index 0a3c28c..dbc6d5e 100644
--- a/dist/Data-Dumper/t/dumper.t
+++ b/dist/Data-Dumper/t/dumper.t
@@ -83,11 +83,11 @@ sub SKIP_TEST {
 $Data::Dumper::Useperl = 1;
 if (defined &Data::Dumper::Dumpxs) {
   print "### XS extension loaded, will run XS tests\n";
-  $TMAX = 420; $XS = 1;
+  $TMAX = 426; $XS = 1;
 }
 else {
   print "### XS extensions not loaded, will NOT run XS tests\n";
-  $TMAX = 210; $XS = 0;
+  $TMAX = 213; $XS = 0;
 }
 
 print "1..$TMAX\n";
@@ -1555,4 +1555,21 @@ EOW
     "\\ octal followed by unicode digit";
   TEST q(Data::Dumper->Dumpxs(["\\x00\\x{0660}"])), '\\ octal followed by unicode digit (xs)'
     if $XS;
+
+  # [perl #118933 - handling of digits
+$WANT = <<'EOW';
+#$VAR1 = 0;
+#$VAR2 = 1;
+#$VAR3 = 90;
+#$VAR4 = -10;
+#$VAR5 = "010";
+#$VAR6 = 112345678;
+#$VAR7 = "1234567890";
+EOW
+  TEST q(Data::Dumper->Dump([0, 1, 90, -10, "010", "112345678", "1234567890" ])),
+    "numbers and number-like scalars";
+
+  TEST q(Data::Dumper->Dumpxs([0, 1, 90, -10, "010", "112345678", "1234567890" ])),
+    "numbers and number-like scalars"
+    if $XS;
 }
-- 
1.7.10.4

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @nwc10

On Sun, Jul 21, 2013 at 10​:34​:22PM -0700, Tony Cook via RT wrote​:

+/* Check that the SV can be represented as a simple decimal integer.
+ *
+ * The perl code does this by matching against /^(?​:0|-?[1-9]\d{0,8})\z/
+*/
+static I32
+safe_decimal_number(SV *val) {

+ return TRUE;

+ return FALSE;

+ return FALSE;

+ return FALSE;

+ return TRUE;
+}

Wouldn't that be better as static BOOL?
Fewer I32s, not more, surely? :-)

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

On Mon, Jul 22, 2013 at 08​:01​:34AM +0100, Nicholas Clark wrote​:

On Sun, Jul 21, 2013 at 10​:34​:22PM -0700, Tony Cook via RT wrote​:

+/* Check that the SV can be represented as a simple decimal integer.
+ *
+ * The perl code does this by matching against /^(?​:0|-?[1-9]\d{0,8})\z/
+*/
+static I32
+safe_decimal_number(SV *val) {

+ return TRUE;

+ return FALSE;

+ return FALSE;

+ return FALSE;

+ return TRUE;
+}

Wouldn't that be better as static BOOL?
Fewer I32s, not more, surely? :-)

I'll fix that.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 22, 2013

From @tonycoz

On Mon Jul 22 02​:57​:17 2013, tonyc wrote​:

On Mon, Jul 22, 2013 at 08​:01​:34AM +0100, Nicholas Clark wrote​:

Wouldn't that be better as static BOOL?
Fewer I32s, not more, surely? :-)

I'll fix that.

Applied with fix as 059639d.

I've opened a ticket against Project​::Easy​:

https://rt.cpan.org/Ticket/Display.html?id=87171

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2013

From @tonycoz

On Mon Jul 22 16​:54​:17 2013, tonyc wrote​:

On Mon Jul 22 02​:57​:17 2013, tonyc wrote​:

On Mon, Jul 22, 2013 at 08​:01​:34AM +0100, Nicholas Clark wrote​:

Wouldn't that be better as static BOOL?
Fewer I32s, not more, surely? :-)

I'll fix that.

Applied with fix as 059639d.

I've opened a ticket against Project​::Easy​:

https://rt.cpan.org/Ticket/Display.html?id=87171

Since I've fixed the problem causing autobox-dump to fail, and reported
the issue in Project​::Easy, I'm closing this ticket.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2013

@tonycoz - 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