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
Benchmark.pm cmpthese segfault #6892
Comments
From mjp-perl-ZYsBlwkHGFY@pilcrow.madison.wi.usCreated by mjp@box.securepipe.comEmpty hashref to Benchmark::cmpthese gives segfault. $ ./perl-5.8.2-RC1 -MBenchmark=:all -e 'cmpthese(10, {})' $ ./perl-5.8.2-RC1 -MBenchmark=:all -e 'cmpthese(timethese(1, {}))' Also observed under 5.8.1. Perl Info
|
From stas@stason.orgmjp-perl-ZYsBlwkHGFY@pilcrow.madison.wi.us (via RT) wrote:
Here is the "fix" that prevent the segfault conditions. Though there is more Inline Patch--- Benchmark.pm.orig 2003-11-05 00:36:58.000000000 -0800
+++ Benchmark.pm 2003-11-05 00:38:26.000000000 -0800
@@ -890,7 +890,7 @@
@vals = sort { $a->[7] <=> $b->[7] } @vals;
# If more than half of the rates are greater than one...
- my $display_as_rate = $vals[$#vals>>1]->[7] > 1;
+ my $display_as_rate = @vals ? ($vals[$#vals>>1]->[7] > 1) : 0;
my @rows;
my @col_widths;
av.c: The segfault conditions are easy to reproduce outside the reported one liner: % perl-5.8.2-ithread -le '@a; $a[2**31-1] = 5' so it does with 2**30-1 and so with 2*29, the only successful one was: perl-5.8.2-ithread -le '@a; $a[2**27-1] = 5' which almost ate all my memory I think it's really malloc that fails, but the if you look at the core file (gdb) where Luckily interactive debugging was much more to the point. And the gdb macro: define curinfo has shown me where in the perl code the problem comes from. __________________________________________________________________ |
From @schwernOn Wed, Nov 05, 2003 at 12:50:25AM -0800, Stas Bekman wrote:
Since $foo>>1 is just an clever way to say int $foo/2, but in an alien my $display_as_rate = no? -- |
From stas@stason.orgMichael G Schwern wrote:
$vals[-1/2] == $vals[0], is wrong in any case, since @vals == 0; I wonder why: % perl -le '@a; print $#a' Shouldn't $#a be undef or something? I guess it doesn't matter if someone is In any case perl shouldn't segfault on $a[2**31-1]. __________________________________________________________________ |
From @AbigailOn Wed, Nov 05, 2003 at 02:18:11AM -0800, Stas Bekman wrote:
No, it shouldn't. 'undef' in numeric context is 0. If $#array would no longer holds for all arrays, but only for non-empty ones. You also wouldn't be able to slice as easily anymore. Cases like: my @slice_to_end = @array [$from .. $#array]; would need to be special cases. Abigail |
From @mjdominus
Changing $#a to undef for empty arrays would probaly break more than for my and this: for (my $i=0; and this: and even this: if ($#ARGV == -1) { ... } Not all of these are good style, but they are still common.
|
From @rgsStas Bekman wrote:
Thanks, applied as #21671. |
@rgs - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#24398 (status was 'resolved')
Searchable as RT24398$
The text was updated successfully, but these errors were encountered: