develooper Front page | perl.perl5.porters | Postings from December 2017

[perl #132638] I've discovered a segfault

Thread Next
From:
James E Keenan via RT
Date:
December 22, 2017 20:53
Subject:
[perl #132638] I've discovered a segfault
Message ID:
rt-4.0.24-31365-1513975961-1542.132638-15-0@perl.org
On Thu, 21 Dec 2017 09:52:59 GMT, DaTa wrote:
> 
> This is a bug report for perl from data@cpan.org,
> generated with the help of perlbug 1.40 running under perl 5.26.1.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Hi,
> 
> i've run accross a segmentation fault with the following script:
> 
> package Clock;
> use 5.010;
> use strict;
> 
> use overload
> '+' => \&add_time,
> '-' => \&sub_time,
> 'eq' => \&equals_to,
> '""' => \&to_string;
> 
> sub equals_to{ $_[0] eq $_[1] }
> sub to_string { sprintf '%02d:%02d', $_[0][0] // 0, $_[0][1] // 0; }
> sub new { bless( $_[1], $_[0] ); }
> 
> package main;
> Clock->new([8,0]) eq "08:00"
> __END__
> 
> The SIGSEGV goes away when I change equals_to to:
> 
> sub equals_to{ $_[0]->to_string eq $_[1] }
> 
> bye,
> 
> Danijel
> 

Confirmed.  Note that the problem is older than the perl-5.010 needed to make use of the '//' operator in sub to_string().  If we switch those to '||', we can reproduce the segfault going back at least to perl 5.6.  See attached.

Thank you very much.

-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=132638

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