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

String results of glob operator #9131

Open
p5pRT opened this issue Nov 25, 2007 · 8 comments
Open

String results of glob operator #9131

p5pRT opened this issue Nov 25, 2007 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 25, 2007

Migrated from rt.perl.org#47780 (status was 'open')

Searchable as RT47780$

@p5pRT
Copy link
Author

p5pRT commented Nov 25, 2007

From xueweizhong@gmail.com

Created by xueweizhong@gmail.com

Just try the 2 commands below​:

perl -e 'local $" = ","; print join ",", <a{@​{[q{001}..q{064}]}}>'
a001,a002,a003,a004,a005,a006,a007,a008,a009,a010,a011,a012,a013,a014,a015,a016,a017,a018,a019,a020,a021,a022,a023,a024,a025,a026,a027,a028,a029,a030,a031,a032,a033,a034,a035,a036,a037,a038,a039,a040,a041,a042,a043,a044,a045,a046,a047,a048,a049,a050,a051,a052,a053,a054,a055,a056,a057,a058,a059,a060,a061,a062,a063,a064

perl -e 'local $" = ","; print join ",", <a{@​{[q{001}..q{065}]}}>'
a

The only difference between these 2 commands are `064' and `065', but why the results are so different?

Is this caused by language feature or bug?

Perl Info

Flags:
    category=library
    severity=high

Site configuration information for perl v5.8.8:

Configured by rurban at Sun Jul  8 19:08:44 GMT 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=cygwin, osvers=1.5.24(0.15642), archname=cygwin-thread-multi-64int
    uname='cygwin_nt-5.1 reini 1.5.24(0.15642) 2007-01-31 10:57 i686 cygwin '
    config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -Uusemymalloc -Doptimize=-O3 -Dman3ext=3pm -Dusesitecustomize -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -Wdeclaration-after-statement',
    optimize='-O3',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -Wdeclaration-after-statement'
    ccversion='', gccversion='3.4.4 (cygming special, gdc 0.12, using dmd 0.125)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -ldb -ldl -lcrypt -lgdbm_compat
    perllibs=-ldl -lcrypt -lgdbm_compat
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Locally applied patches:
    CYG01 - hints.cygwin.sh ldflags -s
    CYG02 - lib-ExtUtils-Embed insensitive against leading \\s
    CYG03 - lib-Test-Harness-Straps $ENV{PERL5LIB} = ''
    CYG04 - major.version.cygwin.sh cygperl-5_8.dll and not cygperl-5_8_x.dll
    CYG05 - add Win32CORE to core
    CYG07 - File-Spec-Cygwin-TMPDIR.patch
    Bug#38628 - allow legacy Cwd->cwd()
    Bug#40103 - File-Spec-case_tolerant.patch from 5.9.5


@INC for perl v5.8.8:
    /usr/lib/perl5/5.8/cygwin
    /usr/lib/perl5/5.8
    /usr/lib/perl5/site_perl/5.8/cygwin
    /usr/lib/perl5/site_perl/5.8
    /usr/lib/perl5/site_perl/5.8
    /usr/lib/perl5/vendor_perl/5.8/cygwin
    /usr/lib/perl5/vendor_perl/5.8
    /usr/lib/perl5/vendor_perl/5.8
    .


Environment for perl v5.8.8:
    CYGWIN=ntsec tty
    HOME=/home/wexue
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/wexue/install/lib:/home/wexue/install/lib/amd64:
    LOGDIR (unset)
    PATH=/home/wexue/install/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/wexue/install/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/SYSTEM32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/SYSTEM32/WBEM:/cygdrive/c/DMI/WIN32/BIN:/cygdrive/c/Documents and Settings/wexue/My Documents/software/putty:/usr/bin:/:/cygdrive/c/Program Files/Hummingbird/Connectivity/12.00/Exceed:/cygdrive/c/path:/cygdrive/c/Program Files/Microsoft Office/OFFICE11:/cygdrive/c/path:/cygdrive/c/path:/usr/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2007

From @schwern

xueweizhong@​gmail.com (via RT) wrote​:

Just try the 2 commands below​:

perl -e 'local $" = ","; print join ",", <a{@​{[q{001}..q{064}]}}>'
a001,a002,a003,a004,a005,a006,a007,a008,a009,a010,a011,a012,a013,a014,a015,a016,a017,a018,a019,a020,a021,a022,a023,a024,a025,a026,a027,a028,a029,a030,a031,a032,a033,a034,a035,a036,a037,a038,a039,a040,a041,a042,a043,a044,a045,a046,a047,a048,a049,a050,a051,a052,a053,a054,a055,a056,a057,a058,a059,a060,a061,a062,a063,a064

perl -e 'local $" = ","; print join ",", <a{@​{[q{001}..q{065}]}}>'
a

The only difference between these 2 commands are `064' and `065', but why the results are so different?

Is this caused by language feature or bug?

I am unable to reproduce the problem with 5.8.8 on OS X. I do note that the
first list is 64 (2**6) and the second is 65. It's possible the list has
overflowed something in the glob implementation.

Yep, I fail at 256 with both 5.8.8 and bleadperl.

With my limited knowledge of C, I can take an educated guess that the problem
lies somewhere inside globexp1 or globexp2 in ext/File/Glob/bsd_glob.c.

What's the value of MAXPATHLEN on your system? I see that constant popping up
in the code. Compile and run this bit of C code to find out. Do "gcc try.c
&& ./a.out"

#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>

int
main()
{
  printf("MAXPATHLEN​: %d\n", MAXPATHLEN);

  return 0;
}

--
I have a date with some giant cartoon robots and booze.

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2007

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2007

From xueweizhong@gmail.com

Hi Michael,

What's the value of MAXPATHLEN on your system? I see that constant popping up

See the shell screen below​:

  Todd>cat > glob.c
  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/param.h>

  int
  main()
  {
  printf("MAXPATHLEN​: %d\n", MAXPATHLEN);

  return 0;

  }
  Todd>make glob
  cc glob.c -o glob
  Todd>./glob
  MAXPATHLEN​: 259
  Todd>

Is there word around for this issue?

Thanks
Todd

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2007

From @druud62

Todd schreef​:

MGS​:

What's the value of MAXPATHLEN on your system? I see that constant
popping up

Todd>make glob
cc     glob\.c   \-o glob
Todd>\./glob
MAXPATHLEN&#8203;: 259
Todd>

Is there word around for this issue?

$ perl -wle'
  sub mm {
  my $_0 = shift;
  map {
  my $g = $_;
  map $g.$_, @​_ > 1 ? mm(@​_) : @​{$_[0]}
  } @​$_0
  }
  print for mm ["a".."c"], [1..2], ["y".."z"], [7..9];
'
a1y7
a1y8
...
c2z8
c2z9

--
Affijn, Ruud

"Gewoon is een tijger."

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2007

From @schwern

Todd wrote​:

Todd>make glob
cc     glob\.c   \-o glob
Todd>\./glob
MAXPATHLEN&#8203;: 259
Todd>

Is there word around for this issue?

259? How bizarre. I wonder if that's some hack to take into account extra
trailing nulls or weird off-by-one errors or the 2 byte Windows newline or
something.

--
You know what the chain of command is? It's the chain I go get and beat you
with 'til you understand who's in ruttin' command here.
  -- Jayne Cobb, "Firefly"

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2012

From @doy

I can reproduce this on Linux with 5.16.0, except that the overflow
happens for me when going from

  perl -e 'local $" = ","; print join ",", <a{@​{[q{00001}..q{00682}]}}>'

to

  perl -e 'local $" = ","; print join ",", <a{@​{[q{00001}..q{00683}]}}>'

MAXPATHLEN on my system is 4096.

-doy

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2012

From @doy

Actually, more usefully​:

  perl -e 'local $" = ","; print length join "",
<a{@​{[q{00001}..q{00682}]}}>'

prints "4092", and

  perl -e 'local $" = ","; print length join "", <a{@​{[q{0001}..q{0818}]}}>'

prints "4090" (where 0818 is where this overflows when using 4
characters). So it does look like that could be related to the problem.

-doy

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

No branches or pull requests

2 participants