perl5
perl5 copied to clipboard
Cwd has memcpy source/destination overlap
Module: PathTools::Cwd
Description
Here's some of the errors found by valgrind
../lib/perl5db.t: ==508232== Source and destination overlap in memcpy_chk(0x1ffeffb740, 0x1ffeffb744, 15) ../lib/perl5db.t: ==508232== at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ../lib/perl5db.t: ==508232== by 0x568AF8D: XS_Cwd_abs_path (in /home/khw/perl/test_locale4/lib/auto/Cwd/Cwd.so) ../lib/perl5db.t: ==508232== by 0x21E7A6: Perl_pp_entersub (in /home/khw/perl/test_locale4/perl) ../lib/perl5db.t: ==508232== by 0x214865: Perl_runops_standard (in /home/khw/perl/test_locale4/perl) ../lib/perl5db.t: ==508232== by 0x174AAB: perl_run (in /home/khw/perl/test_locale4/perl) ../lib/perl5db.t: ==508232== by 0x14B501: main (in /home/khw/perl/test_locale4/perl) ../lib/perl5db.t: ==508232== ../lib/File/stat.t: ==508581== Source and destination overlap in memcpy_chk(0x1ffeffb740, 0x1ffeffb744, 15) ../lib/File/stat.t: ==508581== at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ../lib/File/stat.t: ==508581== by 0x66D1F8D: XS_Cwd_abs_path (in /home/khw/perl/test_locale4/lib/auto/Cwd/Cwd.so) ../lib/File/stat.t: ==508581== by 0x21E7A6: Perl_pp_entersub (in /home/khw/perl/test_locale4/perl) ../lib/File/stat.t: ==508581== by 0x214865: Perl_runops_standard (in /home/khw/perl/test_locale4/perl) ../lib/File/stat.t: ==508581== by 0x174AAB: perl_run (in /home/khw/perl/test_locale4/perl) ../lib/File/stat.t: ==508581== by 0x14B501: main (in /home/khw/perl/test_locale4/perl) ../lib/File/stat.t: ==508581== op/coreamp.t: ==514663== Source and destination overlap in memcpy_chk(0x1ffeffb750, 0x1ffeffb754, 15) op/coreamp.t: ==514663== at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) op/coreamp.t: ==514663== by 0x5693F8D: XS_Cwd_abs_path (in /home/khw/perl/test_locale4/lib/auto/Cwd/Cwd.so) op/coreamp.t: ==514663== by 0x21E7A6: Perl_pp_entersub (in /home/khw/perl/test_locale4/perl) op/coreamp.t: ==514663== by 0x214865: Perl_runops_standard (in /home/khw/perl/test_locale4/perl) op/coreamp.t: ==514663== by 0x1749BA: perl_run (in /home/khw/perl/test_locale4/perl) op/coreamp.t: ==514663== by 0x14B501: main (in /home/khw/perl/test_locale4/perl) op/coreamp.t: ==514663== ../lib/File/Copy.t: ==515806== Source and destination overlap in memcpy_chk(0x1ffeffb740, 0x1ffeffb744, 15) ../lib/File/Copy.t: ==515806== at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ../lib/File/Copy.t: ==515806== by 0x66D1F8D: XS_Cwd_abs_path (in /home/khw/perl/test_locale4/lib/auto/Cwd/Cwd.so) ../lib/File/Copy.t: ==515806== by 0x21E7A6: Perl_pp_entersub (in /home/khw/perl/test_locale4/perl) ../lib/File/Copy.t: ==515806== by 0x214865: Perl_runops_standard (in /home/khw/perl/test_locale4/perl) ../lib/File/Copy.t: ==515806== by 0x1749BA: perl_run (in /home/khw/perl/test_locale4/perl) ../lib/File/Copy.t: ==515806== by 0x14B501: main (in /home/khw/perl/test_locale4/perl) ../lib/File/Copy.t: ==515806==
Steps to Reproduce
valgrind ./perl -Ilib t/op/coreamp.t Expected behavior
No valgrind errors Perl configuration
# perl -V output goes here
Summary of my perl5 (revision 5 version 37 subversion 2) configuration: Local Commit: 2be99e554d28284bf689eb425cc18cc2ff26c037 Ancestor: 4fa31e7fcc423df04f9d7ee8d1f612eb0e7c9ff6 Platform: osname=linux osvers=5.15.0-41-generic archname=x86_64-linux-thread-multi uname='linux khw8950 5.15.0-41-generic #44-ubuntu smp wed jun 22 14:20:53 utc 2022 x86_64 x86_64 x86_64 gnulinux ' config_args='-des -Uversiononly -Dprefix=/home/khw/devel -Dusedevel -Doptimize=-O0 -DDEBUGGING -A'optimize=-ggdb3' -Accflags='-Wno-deprecated' -Dman1dir='none' -Dman3dir='none' -Dcc=g++ -Dusecbacktrace -Dusethreads' hint=recommended useposix=true d_sigaction=define useithreads=define usemultiplicity=define use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define Compiler: cc='g++' ccflags ='-D_REENTRANT -D_GNU_SOURCE -Wno-deprecated -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2' optimize='-O0 -ggdb3' cppflags='-D_REENTRANT -D_GNU_SOURCE -Wno-deprecated -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include' ccversion='' gccversion='10.3.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='g++' ldflags =' -fstack-protector-strong -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64 libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/x86_64-linux-gnu/libc.so.6 so=so useshrplib=false libperl=libperl.a gnulibc_version='2.35' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E' cccdlflags='-fPIC' lddlflags='-shared -O0 -ggdb3 -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl): Compile-time options: DEBUGGING HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV PERL_TRACK_MEMPOOL PERL_USE_DEVEL PERL_USE_SAFE_PUTENV 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_LOCALE_TIME USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API USE_THREAD_SAFE_LOCALE Locally applied patches: 2252a32df71dc72ed923004829b9685176d51884 4ab9398ad210bfcc762c25ef07db9562a9a478ea Built under linux Compiled at Jul 13 2022 09:14:12 %ENV: PERL5OPT="-w" PERL_DIFF_TOOL="wgdiff" PERL_POD_PEDANTIC="1" PERL_TEST_HARNESS_ASAP="1" @INC: lib /home/khw/devel/lib/perl5/site_perl/5.37.2/x86_64-linux-thread-multi /home/khw/devel/lib/perl5/site_perl/5.37.2 /home/khw/devel/lib/perl5/5.37.2/x86_64-linux-thread-multi /home/khw/devel/lib/perl5/5.37.2 /home/khw/devel/lib/perl5/site_perl/5.33.3 /home/khw/devel/lib/perl5/site_perl/5.33.2 /home/khw/devel/lib/perl5/site_perl/5.31.7 /home/khw/devel/lib/perl5/site_perl/5.31.4 /home/khw/devel/lib/perl5/site_perl/5.31.3 /home/khw/devel/lib/perl5/site_perl/5.31.2 /home/khw/devel/lib/perl5/site_perl/5.31.1 /home/khw/devel/lib/perl5/site_perl/5.29.10 /home/khw/devel/lib/perl5/site_perl/5.29.8 /home/khw/devel/lib/perl5/site_perl/5.29.7 /home/khw/devel/lib/perl5/site_perl/5.28.0 /home/khw/devel/lib/perl5/site_perl/5.26.0 /home/khw/devel/lib/perl5/site_perl/5.6.2 /home/khw/devel/lib/perl5/site_perl
I can't reproduce this.
The lack of line numbers in the report is puzzling, it might be that valgrind can't handle -ggdb3 debug info.
I can't reproduce this.
The lack of line numbers in the report is puzzling, it might be that
valgrindcan't handle-ggdb3debug info.
@khwilliamson, what should be our next steps with this problem?
It is no longer happening for me.
I managed to produce a very similar error here:
==2223460== Source and destination overlap in memcpy_chk(0x1ffeff3b60, 0x1ffeff3b65, 64)
==2223460== at 0x48408F0: __memcpy_chk (vg_replace_strmem.c:1593)
==2223460== by 0x4849A3B: memmove (string_fortified.h:40)
==2223460== by 0x4849A3B: bsd_realpath (Cwd.xs:144)
==2223460== by 0x484B22F: XS_Cwd_abs_path (Cwd.xs:614)
==2223460== by 0x29B272: Perl_pp_entersub (pp_hot.c:5457)
==2223460== by 0x249D4C: Perl_runops_debug (dump.c:2730)
==2223460== by 0x17CEDC: Perl_call_sv (perl.c:3117)
==2223460== by 0x180FB7: Perl_call_list (perl.c:5188)
==2223460== by 0x16F321: S_process_special_blocks (op.c:10844)
==2223460== by 0x1724F8: Perl_newATTRSUB_x (op.c:10684)
==2223460== by 0x174DCB: Perl_utilize (op.c:7617)
==2223460== by 0x1DA0B9: Perl_yyparse (perly.y:395)
==2223460== by 0x312907: S_doeval_compile (pp_ctl.c:3729)
==2223460==
but the line mentioned in Cwd.xs is a call to memmove() (which allows for overlap).
This may be a valgrind bug, or a bad interaction between glibc and valgrind, see https://bugs.kde.org/show_bug.cgi?id=453084