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

Coercion of Array ref to Hash ref fails with nested array contents #1427

Closed
p5pRT opened this issue Mar 22, 2000 · 4 comments
Closed

Coercion of Array ref to Hash ref fails with nested array contents #1427

p5pRT opened this issue Mar 22, 2000 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 22, 2000

Migrated from rt.perl.org#2579 (status was 'resolved')

Searchable as RT2579$

@p5pRT
Copy link
Author

p5pRT commented Mar 22, 2000

From twalters@virage.com

Created by twalters@virage.com

The following command causes perl to hang for a long time, adding lots
of undefs to a nested array​:

perl -e 'use Data​::Dumper; $h->{r} = [{a=>[{},{}]},{a=>[{}]}]; print
Dumper($h);$h->{r}->{a}="d";print Dumper($h)'

# Outputs​:

$VAR1 = {
  'r' => [
  {
  'a' => [
  {},
  {}
  ]
  },
  {
  'a' => [
  {}
  ]
  }
  ]
  };

# After a wait of several minutes the modified array is written....

$VAR1 = {
  'r' => [
  {
  'a' => [
  {},
  {}
  ]
  },
  {
  'a' => [
  {}
  ]
  },
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
  undef,
[ ... continues indefinitely ... ]

Perl Info


Site configuration information for perl 5.00503:

Configured by twalters at Wed Dec 22 14:11:37 PST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos tokyo 5.7 generic sun4u sparc sunw,ultra-2 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-fast', gccversion=
    cppflags=''
    ccflags =''
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G'

Locally applied patches:



@INC for perl 5.00503:
    /export/home2/twalters/Dev/Apps/VSS/lib
    /virage/people/twalters/lib/blib/lib
    /virage/people/twalters/lib/blib/arch
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/virage/people/twalters
    LANG (unset)
    LANGUAGE (unset)

LD_LIBRARY_PATH=/export/home2/twalters/Dev/Local-lib/debug/solaris:/usr/local/lib:/export/home2/twalters/Dev/Local-lib/debug/solaris:/usr/local/lib:/export/home2/twalters/Dev/Local-lib/debug/solaris:/usr/local/lib:/export/home2/twalters/Dev/Local-lib/debug/solaris:/usr/local/lib:/export/home2/twalters/Dev/Local-lib/debug/solaris:/usr/local/lib::/usr/openwin/lib:/opt/SUNWits/Graphics-sw/xil/lib:/usr/galaxy/lib

    LOGDIR (unset)

PATH=/virage/people/twalters/bin:/export/home2/twalters/Dev/bin:/virage/people/twalters/bin:/virage/people/twalters/bin:/virage/people/twalters/bin:/virage/people/twalters/bin:/virage/bin/solaris:/virage/bin:/usr/local/bin/:/usr/bin:.:/usr/etc:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/openwin/bin:/usr/sbin:/usr/ucb:/usr/local/illustra/bin:/usr/local/3dviewnix/PROCESS/BIN

PERLLIB=/export/home2/twalters/Dev/Apps/VSS/lib:/virage/people/twalters/lib/blib/lib:/virage/people/twalters/lib/blib/arch:/usr/local/lib/perl5/5.00503/sun4-solaris:/usr/local/lib/perl5/5.00503:/usr/local/lib/perl5/site_perl/5.005/sun4-solaris:/usr/local/lib/perl5/site_perl/5.005

    PERL_BADLANG (unset)
    SHELL=/bin/tcsh




@p5pRT
Copy link
Author

p5pRT commented Mar 22, 2000

From @gsar

On Wed, 22 Mar 2000 14​:37​:58 PST, Tim Walters wrote​:

The following command causes perl to hang for a long time, adding lots
of undefs to a nested array​:

perl -e 'use Data​::Dumper; $h->{r} = [{a=>[{},{}]},{a=>[{}]}]; print
Dumper($h);$h->{r}->{a}="d";print Dumper($h)'

  % perl5.6.0 -we '$h->{r} = [{a=>[{},{}]},{a=>[{}]}]; $h->{r}->{a}="d";'
  Out of memory!

Data​::Dumper is not involved here. Perl thinks you're accessing the
pseudo-hash element in $h->{r}[ $h->{r}[0]{a} ]. And of course,
$h->{r}[0]{a} amounts to a "numeric" value of 0xfeedface or thereabouts.
You know the rest.

We really oughtta croak on seeing an index that's a reference, but it
needs some care, or bigints etc won't work right.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2002

From @floatingatoll

[RT_System - Wed Mar 22 08​:28​:47 2000]​:

On Wed, 22 Mar 2000 14​:37​:58 PST, Tim Walters wrote​:

perl -e 'use Data​::Dumper; $h->{r} = [{a=>[{},{}]},{a=>[{}]}]; print
Dumper($h);$h->{r}->{a}="d";print Dumper($h)'

% perl5.6.0 -we '$h->{r} = [{a=>[{},{}]},{a=>[{}]}]; $h->{r}->{a}="d";'
Out of memory!

[...]

We really oughtta croak on seeing an index that's a reference, but it
needs some care, or bigints etc won't work right.

As of the perl 5.8/5.9 development track, this code now throw the error "Not a
HASH reference", for both provided examples. I'm resolving this issue; thanks
for the bug report!

- R.

$VAR1 = {
  'r' => [
  {
  'a' => [
  {},
  {}
  ]
  },
  {
  'a' => [
  {}
  ]
  }
  ]
  };
Not a HASH reference at -e line 2.

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 2002

@floatingatoll - Status changed from 'open' to 'resolved'

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

1 participant