On Fri, Jan 23, 2009 at 08:21:24PM +, Marcin Owsiany wrote:
The following program dies for me on perl v5.8.8 with:
Can't call method foo without a package or object reference at a line 10.
8---
package A;
sub new { bless {}, shift }
sub foo { }
sub getref { setpgrp() }
package main;
my $o = A-new;
# my $r = A::getref;
# $o-foo($r);
$o-foo(A::getref);
8---
However just uncomment the commented lines, and comment the last one,
and it works! :-O
Thanks for the report.
This bug is still present in bleadperl. The attached patch should fix it.
--
Niko Tyni nt...@debian.org
From 38bc943b3e930c46bd9043230ab36503f43a657e Mon Sep 17 00:00:00 2001
From: Niko Tyni nt...@debian.org
Date: Mon, 26 Jan 2009 14:14:36 +0200
Subject: [PATCH] setpgrp() should extend the stack before modifying it
As reported by Marcin Owsiany in http://bugs.debian.org/512796,
invoking setpgrp without any arguments could corrupt the stack.
---
pp_sys.c|1 +
t/op/setpgrpstack.t | 16
2 files changed, 17 insertions(+), 0 deletions(-)
create mode 100644 t/op/setpgrpstack.t
diff --git a/pp_sys.c b/pp_sys.c
index cfbf918..0d2c970 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4318,6 +4318,7 @@ PP(pp_setpgrp)
if (MAXARG 2) {
pgrp = 0;
pid = 0;
+ XPUSHi(-1);
}
else {
pgrp = POPi;
diff --git a/t/op/setpgrpstack.t b/t/op/setpgrpstack.t
new file mode 100644
index 000..31f498e
--- /dev/null
+++ b/t/op/setpgrpstack.t
@@ -0,0 +1,16 @@
+#!./perl -w
+
+BEGIN {
+chdir 't' if -d 't';
+@INC = '../lib';
+require './test.pl';
+}
+
+use Config;
+plan tests = 2;
+
+SKIP: {
+skip setpgrp() is not available, 2 unless $Config{d_setpgrp};
+ok(!eval { package A;sub foo { die(got here) }; package main; A-foo(setpgrp())});
+ok($@ =~ /got here/, setpgrp() should extend the stack before modifying it);
+}
--
1.5.6.5