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

[perl #134279] Getopt::Long data corruption

Thread Previous
From:
Kirill Kryukov
Date:
July 11, 2019 04:28
Subject:
[perl #134279] Getopt::Long data corruption
Message ID:
rt-4.0.24-20837-1562738321-601.134279-75-0@perl.org
# New Ticket Created by  Kirill Kryukov 
# Please include the string:  [perl #134279]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=134279 >


This is a bug report for perl from kkryukov@gmail.com,
generated with the help of perlbug 1.41 running under perl 5.30.0.


Getopt::Long corrupts data in pass_through mode. Repro script:

#!/usr/bin/env perl
use Getopt::Long qw(GetOptionsFromArray :config pass_through);
my @opts = ('--opt1', '1', '--name', 'N', '--namezzz', 'ZZZ', '--opt2',
'2');
my $namezzz;
GetOptionsFromArray(\@opts, 'namezzz=s' => \$namezzz);
print join(' ', @opts), "\n";

It produces the following output for me:

--opt1 1 --opt2 2

The expected correct output should be:

--opt1 1 --name N --opt2 2

I.e., the call to GetOptionsFromArray() is supposed to consume only option
"--namezzz ZZZ" from the @opts array, however it also removes "--name N".

This was isolated from a script where downstream code was misbehabing due
to not receiving the expected option.

I reproduced it with perl 5.30.0 on Windows, as well as with perl 5.26.0 on
Linux, so it does not look OS specific.

Changing '--name' to '--name1' restores the correct behavior. So, it seems
that the bug occurs for two options with names such that one is the prefix
of another.




---
Flags:
    category=library
    severity=high
    module=Getopt::Long
---
Site configuration information for perl 5.30.0:

Configured by strawberry-perl at Thu May 23 12:21:57 2019.

Summary of my perl5 (revision 5 version 30 subversion 0) configuration:

  Platform:
    osname=MSWin32
    osvers=10.0.17763.529
    archname=MSWin32-x64-multi-thread
    uname='Win32 strawberry-perl 5.30.0.1 #1 Thu May 23 12:20:46 2019 x64'
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE
-D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing
-mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"C:\utl\Dev\STRAWB~1\perl\lib\CORE"
-L"C:\utl\Dev\STRAWB~1\c\lib"'
    libpth=C:\utl\Dev\STRAWB~1\c\lib
C:\utl\Dev\STRAWB~1\c\x86_64-w64-mingw32\lib
C:\utl\Dev\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\8.3.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl530.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=xs.dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"C:\utl\Dev\STRAWB~1\perl\lib\CORE"
-L"C:\utl\Dev\STRAWB~1\c\lib"'


---
@INC for perl 5.30.0:
    C:/utl/Dev/StrawberryPerl/perl/site/lib
    C:/utl/Dev/StrawberryPerl/perl/vendor/lib
    C:/utl/Dev/StrawberryPerl/perl/lib

---
Environment for perl 5.30.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=C:\utl\Dev\StrawberryPerl\c\bin;C:\utl\Dev\StrawberryPerl\perl\site\bin;C:\utl\Dev\StrawberryPerl\perl\bin;C:\utl\bin\tools;C:\utl\bin\bio;C:\utl\bin\dev;C:\utl\bin\cygwin64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\Kirr\AppData\Local\Microsoft\WindowsApps;
    PERL_BADLANG (unset)
    SHELL (unset)


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