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

Segfault on Perl 5.10.0 with Test2::Plugin::UTF8 + subtest + Test2::Mock #129

plicease opened this issue Aug 8, 2017 · 8 comments


Copy link

@plicease plicease commented Aug 8, 2017

With this test script:

use Test2::Plugin::UTF8;
use Test2::Bundle::More;
use Test2::Mock;
use ExtUtils::MakeMaker;

ok 1;

my $mock = Test2::Mock->new(
  class => 'ExtUtils::MakeMaker',

subtest 'user says yes' => sub {

  my($msg, $def);

  $mock->override(prompt => sub ($;$) { ($msg,$def) = @_; return 'y' });

  ok 1;


detailed log:

Discovered from a real test from cpantesters for Alien-Build-Plugin-Fetch-Prompt 0.58
which seems to fail on 5.10.0 on multiple platforms. I can workaround this by using -no_utf8 => 1 since I'm not generating UTF8 output in that test, so this is non-urgent for me atm, but wanted to report it, since my workaround is going to hide the bug.

Copy link

@colinnewell colinnewell commented Oct 6, 2017

I suspect I'm seeing the same issue with a different module, just using Test2::V0. It looks like the same sort of crash. This is the stack trace from gdb.

Program received signal SIGSEGV, Segmentation fault.
0x000055555561e6ad in S_swash_get ()
(gdb) bt
#0  0x000055555561e6ad in S_swash_get ()
#1  0x0000555555620eb0 in Perl_swash_fetch ()
#2  0x0000555555613642 in S_regrepeat ()
#3  0x0000555555617993 in S_regtry ()
#4  0x000055555561e14d in Perl_regexec_flags ()
#5  0x00005555555c4bda in Perl_pp_match ()
#6  0x00005555555c116d in Perl_runops_standard ()
#7  0x00005555555bc45e in Perl_call_sv ()
#8  0x00005555555cd98a in Perl_sv_clear ()
#9  0x00005555555ce0f8 in Perl_sv_free2 ()
#10 0x00005555555ca227 in S_visit ()
#11 0x00005555555ca811 in Perl_sv_clean_objs ()
#12 0x00005555555bd38c in perl_destruct ()
#13 0x000055555557c280 in main ()

This is limited to just perl 5.10.0, and does not happen with 5.10.1, so I'm not really sure how important this is. It looks like it's crashing at some point while going through perl's shutdown.

   0x000055555561e69a <+234>:	mov    $0x20,%r9d
   0x000055555561e6a0 <+240>:	mov    $0x6,%ecx
   0x000055555561e6a5 <+245>:	mov    %rax,%rbx
   0x000055555561e6a8 <+248>:	callq  0x5555555b5b00 <Perl_hv_common>
=> 0x000055555561e6ad <+253>:	mov    (%r12),%rdi
   0x000055555561e6b1 <+257>:	mov    %rax,0x68(%rsp)
   0x000055555561e6b6 <+262>:	pop    %rsi

At that point r12 is 0

r12            0x0	0
Copy link

@colinnewell colinnewell commented Oct 6, 2017

If I comment out the destructor on Test2::Mock that does prevent the crash.

Copy link

@exodist exodist commented Oct 6, 2017

  1. What GCC was 5.10 compiled on?
  2. Was the perl built with threads?

There are some known issues with 5.10 built with threads on newer gcc's that cannot be worked around, but I am not yet ready to say this is the cause here. Need more info.

Copy link

@colinnewell colinnewell commented Oct 6, 2017

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) 
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
    osname=linux, osvers=4.10.0-35-generic, archname=x86_64-linux
    uname='linux andromeda 4.10.0-35-generic #39-ubuntu smp wed sep 13 07:46:59 utc 2017 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/colin/perl5/perlbrew/perls/perl-5.10.0 -Aeval:scriptdir=/home/colin/perl5/perlbrew/perls/perl-5.10.0/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='6.3.0 20170406', 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='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -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 -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'

Characteristics of this binary (from libperl): 
                        USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
  Locally applied patches:
	Devel::PatchPerl 1.48
  Built under linux
  Compiled at Oct  6 2017 14:00:37
Copy link

@colinnewell colinnewell commented Oct 6, 2017

It seems to be on this line of Test2::Util::Stash where it is crashing.

    my ($sig, $pkg, $name) = ($symbol =~ m/^(\W?)(.*::)?([^:]+)$/)
        or croak "Invalid symbol: '$symbol'";
Copy link

@colinnewell colinnewell commented Oct 6, 2017

Early on when the script is starting up,

  DB<4> Dump($symbol)
SV = PV(0x555ec68b3808) at 0x555ec5ca1708
  REFCNT = 2
  PV = 0x555ec688ec40 "&request"\0 [UTF8 "&request"]
  CUR = 8
  LEN = 16

  DB<5> x $symbol =~ m/^(\W?)(.*::)?([^:]+)$/
0  '&'
1  undef
2  'request'

Then when the destructor is invoked,

  DB<6> Dump($symbol)
SV = PVMG(0x555ec69fe240) at 0x555ec5ca1708
  REFCNT = 2
  IV = 0
  NV = 0
  PV = 0x555ec5dcbfe0 "&request"\0 [UTF8 "&request"]
  CUR = 8
  LEN = 16

  DB<7> x $symbol =~ m/^(\W?)(.*::)?([^:]+)$/
Signal SEGV at /home/colin/perl5/perlbrew/perls/perl-5.10.0/lib/5.10.0/ line 638
	DB::eval called at /home/colin/perl5/perlbrew/perls/perl-5.10.0/lib/5.10.0/ line 3434
	DB::DB called at /home/colin/perl5/perlbrew/perls/perl-5.10.0/lib/site_perl/5.10.0/Test2/Util/ line 63
	Test2::Util::Stash::_parse_symbol('Test2::Mock', '&request', 'REST::Client') called at /home/colin/perl5/perlbrew/perls/perl-5.10.0/lib/site_perl/5.10.0/Test2/Util/ line 45
	Test2::Util::Stash::parse_symbol('&request', 'REST::Client') called at /home/colin/perl5/perlbrew/perls/perl-5.10.0/lib/site_perl/5.10.0/Test2/ line 394
Copy link

@colinnewell colinnewell commented Oct 6, 2017

This is ugly but seems to prevent the crash.

diff --git a/lib/Test2/Util/ b/lib/Test2/Util/
index b5c1627..4831d68 100644
--- a/lib/Test2/Util/
+++ b/lib/Test2/Util/
@@ -58,6 +58,7 @@ sub _parse_symbol {
         return $symbol;
+    utf8::downgrade($symbol); # prevent crash on 5.10.0
     my ($sig, $pkg, $name) = ($symbol =~ m/^(\W?)(.*::)?([^:]+)$/)
         or croak "Invalid symbol: '$symbol'";
colinnewell added a commit to cv-library/Test2-Suite that referenced this issue Oct 6, 2017
Makes use of test case from issue.
exodist added a commit that referenced this issue Oct 7, 2017
Fix issue #129 with perl 5.10.0
Copy link

@exodist exodist commented Oct 15, 2017

Just released a TRIAL with this, gonna close the issue, Tomorrow, assuming no issues, I will release a non-trial.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.