develooper Front page | perl.perl5.porters | Postings from March 2007

[perl #41736] Test::More::is_deeply crashes when comparing undef to a reference

Thread Next
From:
Jeremy Hetzler
Date:
March 7, 2007 13:52
Subject:
[perl #41736] Test::More::is_deeply crashes when comparing undef to a reference
Message ID:
rt-3.6.HEAD-30201-1173303981-1747.41736-75-0@perl.org
# New Ticket Created by  Jeremy Hetzler 
# Please include the string:  [perl #41736]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41736 >


This is a bug report for perl from jeremyhetzler@gmail.com,
generated with the help of perlbug 1.35 running under perl v5.8.7.


-----------------------------------------------------------------
[Please enter your report here]

Test::More::is_deeply crashes when trying to compare undef to
a hashref or arrayref. When this happens, the remainder of the
tests are not run. is() does not have the bug.

See sample program and output below.

--- SAMPLE PROGRAM ---
#!/bin/perl
use strict;
use warnings;
use Test::More qw( no_plan );
is(         undef,  'foo',  'undef is scalar: no crash'         );
is(         undef,  {},     'undef is hashref: no crash'        );
is(         undef,  [],     'undef is arrayref: no crash'       );

is_deeply(  undef,  'foo',  'undef is_deeply scalar: no crash'  );
is_deeply(  undef,  {},     'undef is_deeply hashref: crashes'  ); # !
is_deeply(  undef,  [],     'undef is_deeply arrayref: crashes' ); # !
is_deeply(  1,      1,      'never executed'                    ); # !
----------------------

--- OUTPUT ---
not ok 1 - undef is scalar: no crash
#     Failed test (./break_test_more at line 9)
#          got: undef
#     expected: 'foo'
not ok 2 - undef is hashref: no crash
#     Failed test (./break_test_more at line 10)
#          got: undef
#     expected: 'HASH(0x10010f18)'
not ok 3 - undef is arrayref: no crash
#     Failed test (./break_test_more at line 11)
#          got: undef
#     expected: 'ARRAY(0x10010f18)'
not ok 4 - undef is_deeply scalar: no crash
#     Failed test (./break_test_more at line 12)
#          got: undef
#     expected: 'foo'
not ok 5 - undef is_deeply hashref: crashes
#     Failed test (./break_test_more at line 14)
Modification of non-creatable array value attempted, subscript -1 at 
/usr/lib/perl5/5.8/Test/More.pm line 1068.
1..5
# Looks like you failed 5 tests of 5.
# Looks like your test died just after 5.
---------------



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
     category=library
     severity=medium
---
Site configuration information for perl v5.8.7:

Configured by gerrit at Fri Dec 30 02:40:15     2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
   Platform:
     osname=cygwin, osvers=1.5.18(0.13242), 
archname=cygwin-thread-multi-64int
     uname='cygwin_nt-5.1 inspiron 1.5.18(0.13242) 2005-07-02 20:30 i686 
unknown unknown cygwin '
     config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads 
-Uusemymalloc -Doptimize=-O3 -Dman3ext=3pm -Dusesitecustomize'
     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 -I/usr/local/include',
     optimize='-O3',
     cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe 
-I/usr/local/include'
     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 /lib /usr/lib
     libs=-lgdbm -ldb -lcrypt -lgdbm_compat
     perllibs=-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:
     SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962

---
@INC for perl v5.8.7:
     /home/steveb/lib/perl
     lib
     /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/cygwin
     /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/cygwin
     /usr/lib/perl5/vendor_perl/5.8
     .

---
Environment for perl v5.8.7:
     HOME=/home/steveb
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR=/home/steveb/log
 
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/home/steveb/scripts:/d/Programs/putty:/c/Program 
Files/FLAC:/d/programs/MKVtoolnix:/c/Program Files/WinRAR/
     PERL5LIB=/home/steveb/lib/perl:lib
     PERLIO=perlio
     PERL_BADLANG (unset)
     SHELL=/usr/bin/bash


Thread Next


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