Fix a memory leak when spawning threads in a BEGIN phase
This commit is contained in:
parent
bf70c3addf
commit
be29c61cdb
|
@ -0,0 +1,49 @@
|
||||||
|
From 803bd7c91c63f8f263bed592a33b10cf69f567cf Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Mitchell <davem@iabyn.com>
|
||||||
|
Date: Fri, 22 Mar 2019 15:43:56 +0000
|
||||||
|
Subject: [PATCH] fix leak in BEGIN { threads->new(...) }
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Normally by the time we reach perl_destruct(), PL_parser should be null
|
||||||
|
due to having its original (null) value restored by SAVEt_PARSER during
|
||||||
|
leaving scope (usually before run-time starts in fact). But if a thread
|
||||||
|
is created within a BEGIN block, the parser is duped, but the
|
||||||
|
SAVEt_PARSER savestack entry isn't. So PL_parser never gets cleaned up.
|
||||||
|
Clean it up in perl_destruct() instead. This is a bit of a hack.
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
perl.c | 15 +++++++++++++++
|
||||||
|
1 file changed, 15 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/perl.c b/perl.c
|
||||||
|
index cdefa99018..1ef425bb25 100644
|
||||||
|
--- a/perl.c
|
||||||
|
+++ b/perl.c
|
||||||
|
@@ -668,6 +668,21 @@ perl_destruct(pTHXx)
|
||||||
|
FREETMPS;
|
||||||
|
assert(PL_scopestack_ix == 0);
|
||||||
|
|
||||||
|
+ /* normally when we get here, PL_parser should be null due to having
|
||||||
|
+ * its original (null) value restored by SAVEt_PARSER during leaving
|
||||||
|
+ * scope (usually before run-time starts in fact).
|
||||||
|
+ * But if a thread is created within a BEGIN block, the parser is
|
||||||
|
+ * duped, but the SAVEt_PARSER savestack entry isn't. So PL_parser
|
||||||
|
+ * never gets cleaned up.
|
||||||
|
+ * Clean it up here instead. This is a bit of a hack.
|
||||||
|
+ */
|
||||||
|
+ if (PL_parser) {
|
||||||
|
+ /* stop parser_free() stomping on PL_curcop */
|
||||||
|
+ PL_parser->saved_curcop = PL_curcop;
|
||||||
|
+ parser_free(PL_parser);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/* Need to flush since END blocks can produce output */
|
||||||
|
/* flush stdout separately, since we can identify it */
|
||||||
|
#ifdef USE_PERLIO
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
|
@ -279,6 +279,10 @@ Patch60: perl-5.28.1-Fix-POSIX-mblen-mbstate_t-initialization-on-threaded
|
||||||
# Fix a memory leak when cloning a regular expression, in upstream after 5.29.9
|
# Fix a memory leak when cloning a regular expression, in upstream after 5.29.9
|
||||||
Patch61: perl-5.29.9-fix-leak-in-cloned-regexes.patch
|
Patch61: perl-5.29.9-fix-leak-in-cloned-regexes.patch
|
||||||
|
|
||||||
|
# Fix a memory leak when spawning threads in a BEGIN phase,
|
||||||
|
# in upstream after 5.29.9
|
||||||
|
Patch62: perl-5.29.9-fix-leak-in-BEGIN-threads-new.patch
|
||||||
|
|
||||||
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
||||||
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
||||||
|
|
||||||
|
@ -2896,6 +2900,7 @@ Perl extension for Version Objects
|
||||||
%patch59 -p1
|
%patch59 -p1
|
||||||
%patch60 -p1
|
%patch60 -p1
|
||||||
%patch61 -p1
|
%patch61 -p1
|
||||||
|
%patch62 -p1
|
||||||
%patch200 -p1
|
%patch200 -p1
|
||||||
%patch201 -p1
|
%patch201 -p1
|
||||||
|
|
||||||
|
@ -2949,6 +2954,7 @@ perl -x patchlevel.h \
|
||||||
'Fedora Patch59: Fix a buffer overread when parsing a regular expression with an unknown character name (RT#133880)' \
|
'Fedora Patch59: Fix a buffer overread when parsing a regular expression with an unknown character name (RT#133880)' \
|
||||||
'Fedora Patch60: Fix mbstate_t initialization in POSIX::mblen (RT#133928)' \
|
'Fedora Patch60: Fix mbstate_t initialization in POSIX::mblen (RT#133928)' \
|
||||||
'Fedora Patch61: Fix a memory leak when cloning a regular expression' \
|
'Fedora Patch61: Fix a memory leak when cloning a regular expression' \
|
||||||
|
'Fedora Patch62: Fix a memory leak when spawning threads in a BEGIN phase' \
|
||||||
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
||||||
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||||
%{nil}
|
%{nil}
|
||||||
|
@ -5244,6 +5250,7 @@ popd
|
||||||
character name (RT#133880)
|
character name (RT#133880)
|
||||||
- Fix mbstate_t initialization in POSIX::mblen (RT#133928)
|
- Fix mbstate_t initialization in POSIX::mblen (RT#133928)
|
||||||
- Fix a memory leak when cloning a regular expression
|
- Fix a memory leak when cloning a regular expression
|
||||||
|
- Fix a memory leak when spawning threads in a BEGIN phase
|
||||||
|
|
||||||
* Tue Mar 05 2019 Björn Esser <besser82@fedoraproject.org> - 4:5.28.1-434
|
* Tue Mar 05 2019 Björn Esser <besser82@fedoraproject.org> - 4:5.28.1-434
|
||||||
- Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)
|
- Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)
|
||||||
|
|
Loading…
Reference in New Issue