develooper Front page | perl.perl5.porters | Postings from September 2013

[perl #119829] usemymalloc cannot handle long strings

From:
Father Chrysostomos
Date:
September 15, 2013 21:01
Subject:
[perl #119829] usemymalloc cannot handle long strings
Message ID:
rt-3.6.HEAD-1873-1379278889-1158.119829-75-0@perl.org
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #119829]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=119829 >


usemymalloc cannot handle long strings

$ ./perl -Ilib -e 'my $x=" "x(${\2}**31+20);'
Segmentation fault: 11

(gdb) bt
#0  0x000000010007ac70 in fill_pat_4bytes (s=0x1009eda00 "ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??ޭ??"..., nbytes=2147487744, fill=0x1004a9840 "ޭ??ޭ??ޭ??ޭ??????????????????AUTOLOAD") at malloc.c:1158
#1  0x000000010007a51f in morecore (bucket=31) at malloc.c:1772
#2  0x00000001000793ec in Perl_malloc (nbytes=2147479588) at malloc.c:1287
#3  0x000000010007bcd7 in Perl_realloc (mp=0x1009a9468, nbytes=2147483670) at malloc.c:2097
#4  0x000000010025d62c in Perl_sv_grow (my_perl=0x100803200, sv=0x100997460, newlen=2147483670) at sv.c:1532
#5  0x000000010030b6b7 in Perl_pp_repeat (my_perl=0x100803200) at pp.c:1729
#6  0x00000001001b016c in Perl_runops_debug (my_perl=0x100803200) at dump.c:2261
#7  0x0000000100060702 in S_run_body (my_perl=0x100803200, oldscope=1) at perl.c:2500
#8  0x000000010005f6d5 in perl_run (my_perl=0x100803200) at perl.c:2416
#9  0x0000000100001428 in main (argc=3, argv=0x7fff5fbffa80, env=0x7fff5fbffaa0) at perlmain.c:112

For me, it happens with any number larger than 1073745906.

$ ./perl -Ilib -e 'my $x=" "x 1073745907'
Segmentation fault: 11

I am also compiling with mad+threads, if that makes any difference.


Summary of my perl5 (revision 5 version 19 subversion 3) configuration:
  Commit id: a496ca38c9dd66846ae327cc193078aee36ae004
  Platform:
    osname=darwin, osvers=12.2.0, archname=darwin-thread-multi-2level
    uname='darwin pint.local 12.2.0 darwin kernel version 12.2.0: sat aug 25 00:48:52 pdt 2012; root:xnu-2050.18.24~1release_x86_64 x86_64 '
    config_args='-Dusemymalloc -Duseithreads -Dmad -de -Dusedevel -Doptimize=-ggdb3 -Aoptimize=-O0 -DDEBUGGING'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-ggdb3 -O0',
    cppflags='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)', 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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING HAS_TIMES MULTIPLICITY MYMALLOC
                        PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MAD PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        PERL_TRACK_MEMPOOL PERL_USE_DEVEL 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_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Built under darwin
  Compiled at Aug 11 2013 14:54:13
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.19.3/darwin-thread-multi-2level
    /usr/local/lib/perl5/site_perl/5.19.3
    /usr/local/lib/perl5/5.19.3/darwin-thread-multi-2level
    /usr/local/lib/perl5/5.19.3
    /usr/local/lib/perl5/site_perl
    .




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