Re: PerlIO::eol core dumps (illegal instruction) in a docker alpine container

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The culprit supposedly found. fortify-headers makes memcpy() assert
that source and destination shouldn't overlap, and when they do it
calls __builtin_trap():

http://git.2f30.org/fortify-headers/file/include/string.h.html#l46

PerlIO::eol in its turn uses memcpy() to remove symbols from a string
(source and destination overlaps). The questions that are left are:

1) Is fortify-headers too strict, or PerlIO::eol should be fixed?
2) What -O0 has to do with this?

Regards,
Yuri

On Fri, Apr 21, 2023 at 9:02 AM Yuri Kanivetsky
<yuri.kanivetsky@xxxxxxxxx> wrote:
>
> Hi,
>
> $ cat a.sh
> apk add perl-dev perl-utils perl-libwww perl-lwp-protocol-https build-base gdb
> cpan -g PerlIO::eol || true
> tar xf Perl*
> cd Perl*
> sed -Ei '/\bWriteMakefile\b/i\\n$WriteMakefileArgs{OPTIMIZE} = "-g3
> -gdwarf-4 -O";' Makefile.PL
> # sed -Ei '/\bWriteMakefile\b/i\\n$WriteMakefileArgs{OPTIMIZE} =
> "-O0";' Makefile.PL
> perl Makefile.PL
> make install
> cd /app
> gdb -ex 'break PerlIOEOL_fill' -ex r --args perl a.pl
>
> $ cat a.pl
> use strict;
> use warnings;
> open my $fh, '<:raw:eol(LF)', 'a.txt';
> my $l = <$fh>;
> print $l, "\n";
>
> $ echo -e 'line 1\nline 2\r\nline 3' > a.txt
>
> $ docker run --rm -itv $PWD:/app alpine:3.17 sh -eux app/a.sh
> ...
> Breakpoint 1, PerlIOEOL_fill (my_perl=0x7f977d80e020,
> f=0x7f977d7ea180) at eol.xs:117
> 117     {
> (gdb) c
> Continuing.
>
> Program received signal SIGILL, Illegal instruction.
> PerlIOEOL_fill (my_perl=<optimized out>, f=<optimized out>) at eol.xs:132
> 132             Copy(start, ptr, i - start, STDCHAR);
> (gdb) backtrace
> #0  PerlIOEOL_fill (my_perl=<optimized out>, f=<optimized out>) at eol.xs:132
> #1  0x00007f977d970a74 in Perl_PerlIO_fill () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #2  0x00007f977d973353 in PerlIOBase_read () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #3  0x00007f977d9733e9 in PerlIO_getc () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #4  0x00007f977d91a5df in Perl_sv_gets () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #5  0x00007f977d9037de in Perl_do_readline () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #6  0x00007f977d8fe780 in Perl_runops_standard () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #7  0x00007f977d8841ba in perl_run () from
> /usr/lib/perl5/core_perl/CORE/libperl.so
> #8  0x000055ca41b3b1db in main ()
>
> But with -O0 it supposedly works. What's going on here? How do I debug it?
>
> Regards,
> Yuri




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux