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
crash when looking for a nonexistent destructor #10068
Comments
From @ntyniThis is a bug report for perl from Niko Tyni <ntyni@debian.org>, The optimization of empty DESTROY methods introduced in commit % perl -e 'sub M::DESTROY; bless {}, "M"' This is seen in the real world with AutoLoader / AutoSplit, where http://bugs.debian.org/564074 Blead backtrace: Core was generated by `./miniperl -e sub M::DESTROY; bless {}, "M"'. Proposed patch attached. Flags: Site configuration information for perl 5.10.1: Configured by Debian Project at Sat Nov 21 19:18:01 UTC 2009. Summary of my perl5 (revision 5 version 10 subversion 1) configuration: Locally applied patches: @INC for perl 5.10.1: Environment for perl 5.10.1: |
From @ntyni0001-Fix-a-NULL-pointer-dereference-when-looking-for-a-DE.patchFrom 16026715863b1a3a6e99df6686834c9238922539 Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Fri, 8 Jan 2010 21:21:57 +0200
Subject: [PATCH] Fix a NULL pointer dereference when looking for a DESTROY method
The empty DESTROY method optimization introduced by commit
fbb3ee5af3d would crash the interpreter if a DESTROY method
was declared but not actually defined.
This is seen in the real world with AutoLoader / AutoSplit,
where the crash defeats autoloading a DESTROY method.
---
sv.c | 3 ++-
t/op/method.t | 11 ++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/sv.c b/sv.c
index fb82caf..ed4be5f 100644
--- a/sv.c
+++ b/sv.c
@@ -5658,7 +5658,8 @@ Perl_sv_clear(pTHX_ register SV *const sv)
&& !CvCONST(destructor)
/* Don't bother calling an empty destructor */
&& (CvISXSUB(destructor)
- || CvSTART(destructor)->op_next->op_type != OP_LEAVESUB))
+ || (CvSTART(destructor)
+ && (CvSTART(destructor)->op_next->op_type != OP_LEAVESUB))))
{
SV* const tmpref = newRV(sv);
SvREADONLY_on(tmpref); /* DESTROY() could be naughty */
diff --git a/t/op/method.t b/t/op/method.t
index afa8cfb..d2914c4 100644
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -10,7 +10,7 @@ BEGIN {
require "test.pl";
}
-print "1..78\n";
+print "1..79\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -292,3 +292,12 @@ EOT
"check if UNIVERSAL::AUTOLOAD works",
);
}
+{
+ fresh_perl_is(<<'EOT',
+sub M::DESTROY; bless {}, "M" ; print "survived\n";
+EOT
+ "survived",
+ {},
+ "no crash with a declared but missing DESTROY method"
+ );
+}
--
1.6.6
|
@tsee - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#71952 (status was 'resolved')
Searchable as RT71952$
The text was updated successfully, but these errors were encountered: