Skip Menu |
Report information
Id: 132048
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: haukex [at] zero-g.net
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Date: Sat, 9 Sep 2017 16:11:16 +0200
Subject: segfault on opening tied and blessed handle
From: Hauke D <haukex [...] zero-g.net>
To: perlbug [...] perl.org
Download (untitled) / with headers
text/plain 378b
Hi, The attached script segfaults on Perl 5.26.0 (perlbug output is included at the end of the file). On older Perls (tested on 5.10), it appears to drop into an infinite loop. While I'm not sure whether blessing the tied handle itself is a sane thing to do (I was just playing around with tied handles), I'm pretty sure it shouldn't segfault. Thanks, Regards, -- Hauke D

Message body is not shown because sender requested not to inline it.

Date: Sat, 9 Sep 2017 16:48:36 +0100
From: Zefram <zefram [...] fysh.org>
Subject: Re: [perl #132048] segfault on opening tied and blessed handle
To: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
Hauke D wrote: Show quoted text
> While I'm not sure whether blessing the tied >handle itself is a sane thing to do
What you're doing gets weird earlier than that. Your tie call: tie *$fh, 'Kaboom', $fh; is pretty strange. Normally the arguments coming after the class name do not refer to the thing being tied, but only tell the class how this tied thing should behave. It's also strange for the TIEHANDLE method to return an argument as the tie-mediating object: normally it would construct and return a new object for this purpose. Given how you've overloaded this object to have multiple roles, it's not surprising that there would be some misbehaviour. In fact, since the default behaviour supplied by Tie::StdHandle is to implement operations on the tied handle as the same operations on the tie-mediating object, the expected behaviour here is an infinite recursion as soon as you attempt a tied operation (such as opening). That's the behaviour that I see, for your test program, on every major stable version from 5.10.0 to 5.26.0. Show quoted text
> I'm pretty sure it shouldn't segfault.
Yes, we'd like to avoid that. -zefram
Date: Sat, 9 Sep 2017 12:23:28 -0400
To: perl5-porters [...] perl.org
From: James E Keenan <jkeenan [...] pobox.com>
Subject: Re: [perl #132048] segfault on opening tied and blessed handle
Download (untitled) / with headers
text/plain 737b
On 09/09/2017 10:20 AM, Hauke D wrote: Show quoted text
> # New Ticket Created by Hauke D > # Please include the string: [perl #132048] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=132048 > > > > Hi, > > The attached script segfaults on Perl 5.26.0 (perlbug output is included > at the end of the file). On older Perls (tested on 5.10), it appears to > drop into an infinite loop. While I'm not sure whether blessing the tied > handle itself is a sane thing to do (I was just playing around with tied > handles), I'm pretty sure it shouldn't segfault. > > Thanks, Regards, > -- Hauke D >
I can confirm that removing the 'bless' enables the program to exit normally.
Subject: Re: [perl #132048] segfault on opening tied and blessed handle
From: Hauke D <haukex [...] zero-g.net>
Date: Fri, 22 Sep 2017 14:40:10 +0200
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 1.5k
On 09.09.2017 17:48, Zefram via RT wrote: Show quoted text
> What you're doing gets weird earlier than that.
Agreed :-) This was a "let's see what happens when I do this" kind of experiment - thank you for your explanation as to what exactly is going wrong. My actual code uses two filehandles. Regards, -- Hauke D On 09.09.2017 17:48, Zefram via RT wrote: Show quoted text
> Hauke D wrote:
>> While I'm not sure whether blessing the tied >> handle itself is a sane thing to do
> > What you're doing gets weird earlier than that. Your tie call: > > tie *$fh, 'Kaboom', $fh; > > is pretty strange. Normally the arguments coming after the class name > do not refer to the thing being tied, but only tell the class how this > tied thing should behave. It's also strange for the TIEHANDLE method > to return an argument as the tie-mediating object: normally it would > construct and return a new object for this purpose. > > Given how you've overloaded this object to have multiple roles, it's not > surprising that there would be some misbehaviour. In fact, since the > default behaviour supplied by Tie::StdHandle is to implement operations on > the tied handle as the same operations on the tie-mediating object, the > expected behaviour here is an infinite recursion as soon as you attempt > a tied operation (such as opening). That's the behaviour that I see, for > your test program, on every major stable version from 5.10.0 to 5.26.0. >
>> I'm pretty sure it shouldn't segfault.
> > Yes, we'd like to avoid that. > > -zefram > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org