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

Carp quoting issue #16247

Closed
p5pRT opened this issue Nov 14, 2017 · 13 comments
Closed

Carp quoting issue #16247

p5pRT opened this issue Nov 14, 2017 · 13 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 14, 2017

Migrated from rt.perl.org#132448 (status was 'rejected')

Searchable as RT132448$

@p5pRT
Copy link
Author

p5pRT commented Nov 14, 2017

From tk@giga.or.at

Created by tk@giga.or.at

One of the self tests of Function-Parameters fails with perl-5.26.1
and the included Carp-1.42. When reporting this upstream to the
package author, he analyzed it and claimed that the bug is in Carp.

The original bug report is at
mauke/Function-Parameters#33

The test program that fails and should not fail according to
the Function-Parameters maintainer is​:

#!perl
use strict;
use warnings FATAL => 'all';
use Test​::More;

use Carp;

my $file = __FILE__;
my $line = __LINE__;

{
  package Foo;
  #use Function​::Parameters;
  sub foo { my ($x, $y) = @​_;
  Carp​::confess "$x $y";
  }

  eval {
  foo("abc", "123");
  };

  my $line_confess = $line + 6;
  my $line_foo = $line + 10;

  :​:like($@​, qr/^abc 123 at \Q$file\E line $line_confess\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at \Q$file\E line $line_foo/);
}

SKIP​: { skip "Sub​::Name required", 1 unless eval { require Sub​::Name };

{
  package Bar;
  #use Function​::Parameters;
  *bar = Sub​::Name​::subname(bar => sub { my ($a, $b) = @​_; Carp​::confess($a + $b) });

  eval {
  bar(4, 5);
  };

  my $line_confess = $line + 24;
  my $line_bar = $line + 27;

  :​:like($@​, qr/^9 at \Q$file\E line $line_confess\.?\n\tBar​::bar\(4, 5\) called at \Q$file\E line $line_bar/);
}

}

done_testing;

For me, on NetBSD-8.99.6/amd64 with perl-5.26.1 this gives​:

# perl test
not ok 1
# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo​::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^​:^abc 123 at test line 15\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at test line 19)'
ok 2
1..2
# Looks like you failed 1 test of 2.

Perl Info

Flags:
    category=library
    severity=medium
    module=Carp

Site configuration information for perl 5.26.1:

Configured by root at Mon Oct 23 15:43:11 GMT 2017.

Summary of my perl5 (revision 5 version 26 subversion 1) configuration:
   
  Platform:
    osname=netbsd
    osvers=8.99.5
    archname=x86_64-netbsd-thread-multi
    uname='netbsd 8.99.5 amd64 '
    config_args='-sde -Dldflags= -Wl,-z,relro -Wl,-z,now  -pthread  -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -Duseshrplib -Duseithreads -Uusemymalloc'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -pthread -I/usr/include -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    optimize='-O2 -g -D_FORTIFY_SOURCE=2 -fstack-check	-pthread  -I/usr/include'
    cppflags='-O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -pthread -I/usr/include -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='5.4.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='gcc'
    ldflags =' -Wl,-z,relro -Wl,-z,now -pthread -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -fstack-protector-strong -L/usr/pkg/lib'
    libpth=/lib /usr/lib /usr/pkg/lib
    libs=-lm -lcrypt -lpthread
    perllibs=-lm -lcrypt -lpthread
    libc=/lib/libc.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E  -Wl,-R/usr/pkg/lib/perl5/5.26.0/x86_64-netbsd-thread-multi/CORE'
    cccdlflags='-DPIC -fPIC '
    lddlflags='-shared	-Wl,-z,relro -Wl,-z,now -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -fstack-protector-strong'



@INC for perl 5.26.1:
    /archive/foreign/nfotex/nsl/lib
    /archive/foreign/nfotex/nsl/lib
    /usr/pkg/lib/perl5/site_perl/5.26.0/x86_64-netbsd-thread-multi
    /usr/pkg/lib/perl5/site_perl/5.26.0
    /usr/pkg/lib/perl5/vendor_perl/5.26.0/x86_64-netbsd-thread-multi
    /usr/pkg/lib/perl5/vendor_perl/5.26.0
    /usr/pkg/lib/perl5/5.26.0/x86_64-netbsd-thread-multi
    /usr/pkg/lib/perl5/5.26.0


Environment for perl 5.26.1:
    HOME=/home/wiz
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE (unset)
    LC_TIME (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Nov 15, 2017

From @jkeenan

On Tue, 14 Nov 2017 23​:30​:56 GMT, tk@​giga.or.at wrote​:

This is a bug report for perl from tk@​giga.or.at,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

One of the self tests of Function-Parameters fails with perl-5.26.1
and the included Carp-1.42. When reporting this upstream to the
package author, he analyzed it and claimed that the bug is in Carp.

The original bug report is at
mauke/Function-Parameters#33

The test program that fails and should not fail according to
the Function-Parameters maintainer is​:

#!perl
use strict;
use warnings FATAL => 'all';
use Test​::More;

use Carp;

my $file = __FILE__;
my $line = __LINE__;

{
package Foo;
#use Function​::Parameters;
sub foo { my ($x, $y) = @​_;
Carp​::confess "$x $y";
}

eval {
foo("abc", "123");
};

my $line_confess = $line + 6;
my $line_foo = $line + 10;

:​:like($@​, qr/^abc 123 at \Q$file\E line
$line_confess\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at \Q$file\E
line $line_foo/);
}

SKIP​: { skip "Sub​::Name required", 1 unless eval { require Sub​::Name
};

{
package Bar;
#use Function​::Parameters;
*bar = Sub​::Name​::subname(bar => sub { my ($a, $b) = @​_;
Carp​::confess($a + $b) });

eval {
bar(4, 5);
};

my $line_confess = $line + 24;
my $line_bar = $line + 27;

:​:like($@​, qr/^9 at \Q$file\E line $line_confess\.?\n\tBar​::bar\(4,
5\) called at \Q$file\E line $line_bar/);
}

}

done_testing;

For me, on NetBSD-8.99.6/amd64 with perl-5.26.1 this gives​:

# perl test
not ok 1
# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo​::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^​:^abc 123 at test line
15\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at test line 19)'
ok 2
1..2
# Looks like you failed 1 test of 2.

The second test -- the one where Sub​::Name has been installed and is being used -- appears to be dependent on line numbers hard-coded into the file -- yet the test which is of concern is "failing" only with respect to line numbers. You can get the second test to "pass" simply by manipulating the numbers assigned in these two lines​:

#####
  my $line_confess = $line + 24;
  my $line_bar = $line + 27;
#####

And since it's only the second test that is failing, it is just as likely that this is a bug in Sub​::Name (not part of the core distribution) as it is in Carp.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Nov 15, 2017

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

@p5pRT
Copy link
Author

p5pRT commented Nov 15, 2017

From @mauke

On Wed, 15 Nov 2017 08​:15​:52 -0800, jkeenan wrote​:

On Tue, 14 Nov 2017 23​:30​:56 GMT, tk@​giga.or.at wrote​:

For me, on NetBSD-8.99.6/amd64 with perl-5.26.1 this gives​:

# perl test
not ok 1
# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo​::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^​:^abc 123 at test line
15\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at test line 19)'
ok 2
1..2
# Looks like you failed 1 test of 2.

The second test -- the one where Sub​::Name has been installed and is
being used -- appears to be dependent on line numbers hard-coded into
the file -- yet the test which is of concern is "failing" only with
respect to line numbers. You can get the second test to "pass" simply
by manipulating the numbers assigned in these two lines​:

#####
my $line_confess = $line + 24;
my $line_bar = $line + 27;
#####

And since it's only the second test that is failing, it is just as
likely that this is a bug in Sub​::Name (not part of the core
distribution) as it is in Carp.

The test output is​:

not ok 1
ok 2

The second test is not failing; the first test is.

And the line numbers in the failure are identical​:

# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo​::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^​:^abc 123 at test line
15\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at test line 19)'

"... line 15" and "... line 19" match. The problem is that what should have been pretty-printed as

  Foo​::foo("abc", 123)

by Carp​::confess got emitted as

  Foo​::foo("\"abc\"", 123)

instead.

@p5pRT
Copy link
Author

p5pRT commented Nov 15, 2017

From tk@giga.or.at

On Wed, Nov 15, 2017 at 08​:15​:52AM -0800, James E Keenan via RT wrote​:

On Tue, 14 Nov 2017 23​:30​:56 GMT, tk@​giga.or.at wrote​:

This is a bug report for perl from tk@​giga.or.at,
generated with the help of perlbug 1.40 running under perl 5.26.1.

-----------------------------------------------------------------
[Please describe your issue here]

One of the self tests of Function-Parameters fails with perl-5.26.1
and the included Carp-1.42. When reporting this upstream to the
package author, he analyzed it and claimed that the bug is in Carp.

The original bug report is at
mauke/Function-Parameters#33

The test program that fails and should not fail according to
the Function-Parameters maintainer is​:

#!perl
use strict;
use warnings FATAL => 'all';
use Test​::More;

use Carp;

my $file = __FILE__;
my $line = __LINE__;

{
package Foo;
#use Function​::Parameters;
sub foo { my ($x, $y) = @​_;
Carp​::confess "$x $y";
}

eval {
foo("abc", "123");
};

my $line_confess = $line + 6;
my $line_foo = $line + 10;

:​:like($@​, qr/^abc 123 at \Q$file\E line
$line_confess\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at \Q$file\E
line $line_foo/);
}

SKIP​: { skip "Sub​::Name required", 1 unless eval { require Sub​::Name
};

{
package Bar;
#use Function​::Parameters;
*bar = Sub​::Name​::subname(bar => sub { my ($a, $b) = @​_;
Carp​::confess($a + $b) });

eval {
bar(4, 5);
};

my $line_confess = $line + 24;
my $line_bar = $line + 27;

:​:like($@​, qr/^9 at \Q$file\E line $line_confess\.?\n\tBar​::bar\(4,
5\) called at \Q$file\E line $line_bar/);
}

}

done_testing;

For me, on NetBSD-8.99.6/amd64 with perl-5.26.1 this gives​:

# perl test
not ok 1
# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo​::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^​:^abc 123 at test line
15\.?\n\tFoo​::foo\((["'])abc\1, 123\) called at test line 19)'
ok 2
1..2
# Looks like you failed 1 test of 2.

The second test -- the one where Sub​::Name has been installed and is being used -- appears to be dependent on line numbers hard-coded into the file -- yet the test which is of concern is "failing" only with respect to line numbers. You can get the second test to "pass" simply by manipulating the numbers assigned in these two lines​:

#####
my $line_confess = $line + 24;
my $line_bar = $line + 27;
#####

And since it's only the second test that is failing, it is just as likely that this is a bug in Sub​::Name (not part of the core distribution) as it is in Carp.

Thank you very much.

I think there is a misunderstanding here.

The second test passes fine for me.

The first test fails.

From the test output above​:

not ok 1
ok 2

And when you look at the 'Failed test' lines you see that they
containt 'foo' and not 'bar'.
Thomas

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From zefram@fysh.org

Both tests pass for me, on perl 5.26.1 with Carp 1.42 on amd64 Linux.
I agree that the test is reasonable. This looks more likely to be a core
thing than Carp per se, but it's difficult to tell without seeing it fail.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From @eserte

Dana Wed, 15 Nov 2017 21​:04​:24 -0800, zefram@​fysh.org reče​:

Both tests pass for me, on perl 5.26.1 with Carp 1.42 on amd64 Linux.
I agree that the test is reasonable. This looks more likely to be a core
thing than Carp per se, but it's difficult to tell without seeing it fail.

NetBSD's perl is patched. See ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/ and especially ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/patch-dist_Carp_lib_Carp.pm

Regards,
  Slaven

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From zefram@fysh.org

slaven@​rezic.de via RT wrote​:

ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/patch-dist_Carp_lib_Carp.pm

Aha! Applying that patch makes the test case fail for me, both on 5.26.1
and on blead. The fault lies purely in that patch​: it's introducing a
layer of format_arg() in addition to the one that already exists a few
lines later. The double quoting is exactly what should be expected from
that mistake.

It looks like the patch is derived from a patch for an older version
of Carp, where it was modifying the single layer of format_arg().
Carp changed, moving the format_arg() call after the argument list
truncation (commit e7eb9d6 in late 2012),
and the attempt to update the patch for the new Carp was botched.

No bug relevant to p5p.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From @xsawyerx

On 11/16/2017 08​:36 AM, slaven@​rezic.de via RT wrote​:

Dana Wed, 15 Nov 2017 21​:04​:24 -0800, zefram@​fysh.org reče​:

Both tests pass for me, on perl 5.26.1 with Carp 1.42 on amd64 Linux.
I agree that the test is reasonable. This looks more likely to be a core
thing than Carp per se, but it's difficult to tell without seeing it fail.
NetBSD's perl is patched. See ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/ and especially ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/patch-dist_Carp_lib_Carp.pm

Does anyone know the Perl porters in NetBSD? :)

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From tk@giga.or.at

On Thu, Nov 16, 2017 at 01​:41​:25AM -0800, Sawyer X via RT wrote​:

On 11/16/2017 08​:36 AM, slaven@​rezic.de via RT wrote​:

Dana Wed, 15 Nov 2017 21​:04​:24 -0800, zefram@​fysh.org reče​:

Both tests pass for me, on perl 5.26.1 with Carp 1.42 on amd64 Linux.
I agree that the test is reasonable. This looks more likely to be a core
thing than Carp per se, but it's difficult to tell without seeing it fail.
NetBSD's perl is patched. See ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/ and especially ftp​://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/patches/patch-dist_Carp_lib_Carp.pm

Does anyone know the Perl porters in NetBSD? :)

I can remove the patch from perl in pkgsrc.

Is there a better version available, or should it just be removed
without replacement?
Thomas

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From zefram@fysh.org

Thomas Klausner wrote​:

Is there a better version available, or should it just be removed
without replacement?

It would best be removed without replacement. It is not a successful
workaround for the problem that it's attempting to address, nor can it
ever be made to work. The underlying problem is in the core of perl,
and cannot be fixed anywhere other than the core.

-zefram

@p5pRT p5pRT closed this as completed Nov 16, 2017
@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

@xsawyerx - Status changed from 'open' to 'rejected'

@p5pRT
Copy link
Author

p5pRT commented Nov 16, 2017

From @xsawyerx

On 11/16/2017 11​:22 AM, Zefram wrote​:

Thomas Klausner wrote​:

Is there a better version available, or should it just be removed
without replacement?
It would best be removed without replacement. It is not a successful
workaround for the problem that it's attempting to address, nor can it
ever be made to work. The underlying problem is in the core of perl,
and cannot be fixed anywhere other than the core.

Thank you everyone.

I'm marking the ticket as rejected.

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