develooper Front page | perl.perl5.porters | Postings from June 2019

Re: [perl #133603] 5.29.4 - re/subst.t crashes perl on 64-bitWindows

Thread Previous
From:
Tomasz Konojacki
Date:
June 1, 2019 12:03
Subject:
Re: [perl #133603] 5.29.4 - re/subst.t crashes perl on 64-bitWindows
Message ID:
c47b8f06-7aae-47cd-834d-955536c8931e@www.fastmail.com
On Sat, 1 Jun 2019, at 03:20, sisyphus wrote:
> AFAIK, although we know how to trigger it, we haven't yet identified the bug - and therefore we are still unable to report it.
> 
> I did spend some time a while back trying to create a C script that would demo the issue, but failed miserably.
> 
> Using the mingw64 port of gcc-8.3.0 that ships with StrawberryPerl-5.30.0, I find it's also exhibiting the bug - just like the 8.1.0 and 8.2.1 mingw64 compilers that I had tried earlier.
> 
> Cheers,
> Rob
> 

My findings so far:

1. The attached patch makes it not crash with HAS_BUILTIN_EXPECT commit *not* reverted. It removes LIKELY() from SvGETMAGIC() inside pp_subst().

2. I have attached assembly code of pp_hot.c with and without my patch applied. The difference between them is really tiny:

--- a/C:/Users/xenu/Documents/pp_hot/crashing/pp_hot.s
+++ b/C:/Users/xenu/Documents/pp_hot/not_crashing/pp_hot.s
@@ -10462,6 +10462,8 @@ Perl_pp_subst:
        movq    %rax, %rdx
        call    Perl_sv_setiv
        jmp     .L2429
+.L2379:^M
+       call    Perl_croak_no_modify^M
 .L2617:
        movq    %r12, %rcx
        movq    %r11, %rdx
@@ -10471,8 +10473,6 @@ Perl_pp_subst:
 .L2464:
        subq    -9(%rcx), %rcx
        jmp     .L2463
-.L2379:
-       call    Perl_croak_no_modify
        .seh_endproc
        .section        .text.unlikely,"x"
        .def    Perl_pp_subst.cold.16;  .scl    3;      .type   32;     .endef

Unless I'm missing something, this change is completely harmless. The only difference is Perl_croak_no_modify() call being moved a bit, but the control flow in both versions is *exactly* the same.

That makes me suspect that it's a bug in the linker, which is probably the worst possible scenario, because linkers are extremely hard to debug :(
Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About