public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: Fix regression causing a crash on Lua state reset (#1958095)
@ 2026-11-23 9:33 Panu Matilainen
0 siblings, 0 replies; only message in thread
From: Panu Matilainen @ 2026-11-23 9:33 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : d0c51399dced2fa2ab1e5d3af3705823c8848309
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2021-05-07T15:48:24+03:00
Stats : +117/-3 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/d0c51399dced2fa2ab1e5d3af3705823c8848309?branch=pmatilai-v6
Log:
Fix regression causing a crash on Lua state reset (#1958095)
Also move previously misplaced previous patch to the "already upstream"
section.
---
diff --git a/0001-Fix-regression-wrt-Lua-reinitialization-RhBug-195809.patch b/0001-Fix-regression-wrt-Lua-reinitialization-RhBug-195809.patch
new file mode 100644
index 0000000..ab69faf
--- /dev/null
+++ b/0001-Fix-regression-wrt-Lua-reinitialization-RhBug-195809.patch
@@ -0,0 +1,111 @@
+From 13c96b26978953aff17bd642328d249820214b12 Mon Sep 17 00:00:00 2001
+Message-Id: <13c96b26978953aff17bd642328d249820214b12.1620391180.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 7 May 2021 15:10:13 +0300
+Subject: [PATCH] Fix regression wrt Lua reinitialization (RhBug:1958095)
+
+Commit 2579d3e5ad5d713f2c161b9fb4835366ea4ea291 started storing the Lua
+context in the spec, but this leads to problems as what is actually a
+global context is now stored in two places, and can get out of sync.
+So if you parse a spec, and then reset the global context, you get a
+fancy segfault when the freeing the spec because it's pointing to
+la-la-lua land.
+
+Revert back to always using the global Lua handle.
+---
+ build/parsePreamble.c | 3 ++-
+ build/rpmbuild_internal.h | 1 -
+ build/spec.c | 4 ++--
+ build/speclua.c | 2 +-
+ tests/rpmpython.at | 7 ++++++-
+ 5 files changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/build/parsePreamble.c b/build/parsePreamble.c
+index fc4a2994d..ac3d9159e 100644
+--- a/build/parsePreamble.c
++++ b/build/parsePreamble.c
+@@ -321,7 +321,8 @@ int addSource(rpmSpec spec, int specline, const char *srcname, rpmTagVal tag)
+ rpmPushMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC);
+ free(buf);
+
+- addLuaSource(spec->lua, p);
++ rpmlua lua = rpmluaGetGlobalState();
++ addLuaSource(lua, p);
+
+ if (!nofetch && tryDownload(p))
+ return RPMRC_FAIL;
+diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
+index 2bac303c7..39a9c916f 100644
+--- a/build/rpmbuild_internal.h
++++ b/build/rpmbuild_internal.h
+@@ -138,7 +138,6 @@ struct rpmSpec_s {
+ Package sourcePackage;
+
+ rpmMacroContext macros;
+- rpmlua lua;
+ rpmstrPool pool;
+
+ StringBuf prep; /*!< %prep scriptlet. */
+diff --git a/build/spec.c b/build/spec.c
+index 365ce6d32..6a13afda2 100644
+--- a/build/spec.c
++++ b/build/spec.c
+@@ -249,7 +249,7 @@ rpmSpec newSpec(void)
+ spec->macros = rpmGlobalMacroContext;
+ spec->pool = rpmstrPoolCreate();
+
+- spec->lua = specLuaInit(spec);
++ specLuaInit(spec);
+ return spec;
+ }
+
+@@ -298,7 +298,7 @@ rpmSpec rpmSpecFree(rpmSpec spec)
+
+ // only destroy lua tables if there are no BASpecs left
+ if (spec->recursing || spec->BACount == 0) {
+- spec->lua = specLuaFini(spec);
++ specLuaFini(spec);
+ }
+
+ spec->sources = freeSources(spec->sources);
+diff --git a/build/speclua.c b/build/speclua.c
+index 595d71f14..abf2a4886 100644
+--- a/build/speclua.c
++++ b/build/speclua.c
+@@ -25,7 +25,7 @@ void * specLuaInit(rpmSpec spec)
+
+ void * specLuaFini(rpmSpec spec)
+ {
+- rpmlua lua = spec->lua;
++ rpmlua lua = rpmluaGetGlobalState();
+ lua_State *L = rpmluaGetLua(lua);
+ for (const char **vp = luavars; vp && *vp; vp++) {
+ lua_pushnil(L);
+diff --git a/tests/rpmpython.at b/tests/rpmpython.at
+index 14c6a75dc..8128263e3 100644
+--- a/tests/rpmpython.at
++++ b/tests/rpmpython.at
+@@ -67,7 +67,7 @@ for iot in [ 'fpio', 'fdio', 'ufdio', 'gzdio' ]:
+ ],
+ [])
+
+-RPMPY_TEST([spec parse],[
++RPMPY_TEST([spec parse 1],[
+ # TODO: add a better test spec with sub-packages etc
+ spec = rpm.spec('${RPMDATA}/SPECS/hello.spec')
+ for (name, num, flags) in spec.sources:
+@@ -82,6 +82,11 @@ hello-1.0-1
+ hello-1.0-1
+ ])
+
++RPMPY_TEST([spec parse 2],[
++spec = rpm.spec('${RPMDATA}/SPECS/mini.spec')
++rpm.reloadConfig()
++])
++
+ RPMPY_TEST([basic header manipulation],[
+ h = rpm.hdr()
+ h['name'] = 'testpkg'
+--
+2.30.2
+
diff --git a/rpm.spec b/rpm.spec
index 332e15b..ed4a573 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -32,7 +32,7 @@
%global rpmver 4.16.90
%global snapver git15395
-%global rel 5
+%global rel 6
%global sover 9
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -54,9 +54,9 @@ Patch3: rpm-4.9.90-no-man-dirs.patch
# https://github.com/rpm-software-management/rpm/pull/473
Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
-Patch10: 0001-Ignore-comment-line-contents-in-macro-files-1659.patch
-
# Patches already upstream:
+Patch100: 0001-Ignore-comment-line-contents-in-macro-files-1659.patch
+Patch101: 0001-Fix-regression-wrt-Lua-reinitialization-RhBug-195809.patch
# These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch
@@ -571,6 +571,9 @@ fi
%doc doc/librpm/html/*
%changelog
+* Fri May 07 2021 Panu Matilainen <pmatilai@redhat.com> - 4.16.90-0.git15395.6
+- Fix regression causing a crash on Lua state reset (#1958095)
+
* Thu Apr 29 2021 Panu Matilainen <pmatilai@redhat.com> - 4.16.90-0.git15395.5
- Proper fix for comments affecting macro file parsing (#1953910)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 9:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 9:33 [rpms/rpm] pmatilai-v6: Fix regression causing a crash on Lua state reset (#1958095) Panu Matilainen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox