develooper Front page | perl.perl5.porters | Postings from February 2003

Re: odd (or not so odd?) segmentation fault in 5.8.0

Thread Previous | Thread Next
From:
Mark Mielke
Date:
February 16, 2003 08:37
Subject:
Re: odd (or not so odd?) segmentation fault in 5.8.0
Message ID:
20030216164535.GB21306@mark.mielke.cc
On Thu, Feb 13, 2003 at 03:36:15PM -0500, Benjamin Goldberg wrote:
> > Of course, this is an odd thing to do, and therefore, I'm not
> > surprised that there are no regression tests to catch this. My goal
> > was to use a tie() to provide demand loading of an object. The first
> > time through, access is through a tie() that initializes the object,
> > removes the tie, and returns the object.
> Does the segfault occur if the tie is removed via 'untie($a)'?

This was my first attempt. See:

  $ perl -e 'sub TIESCALAR {bless[]}
  sub FETCH {print "HELLO\n"; untie($a); $a = 1}
  tie($a,__PACKAGE__);print $a, $a, $a, "\n";'
  HELLO
  1HELLO
  1HELLO
  1

It looks as if the untie() has no effect. "HELLO" is printed each time.

Perhaps I should have reported this as the first 'bug'? (I confess to not
finding the above behaviour very surprising... untie()'ing from within a
method called by the tie() seems extremely dangerous...)

I also tried:

  $ perl -e 'sub TIESCALAR {bless[]}
  sub FETCH {*b = *a; *a = \ 1; $a}
  tie($a,__PACKAGE__);print $a, $a, $a, "\n";'
  zsh: segmentation fault  perl -e

My reasoning was that this would keep the object from being dereferenced.

No such luck, it seems. I think this must mean that nobody has ever tried
to use Perl in just this way lately.

mark

-- 
mark@mielke.cc/markm@ncf.ca/markm@nortelnetworks.com __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/


Thread Previous | 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