From 0d467c05d6252e59273afdf3ce08c511514bfc2c Mon Sep 17 00:00:00 2001 From: Guinevere Larsen Date: Mon, 30 Oct 2023 12:54:25 +0100 Subject: [PATCH] Fix issue introduced when backporting recursion limit to rust demangler Resolves: RHEL-7330 --- _gdb.spec.Patch.include | 3 ++ _gdb.spec.patch.include | 1 + _patch_order | 1 + gdb.spec | 5 ++- libiberty-infinite-recursion-fix-3-of-3.patch | 40 +++++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 libiberty-infinite-recursion-fix-3-of-3.patch diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include index 61c0d88..c69b87a 100644 --- a/_gdb.spec.Patch.include +++ b/_gdb.spec.Patch.include @@ -301,3 +301,6 @@ Patch070: libiberty-infinite-recursion-fix-1-of-2.patch # (Nick Clifton) Patch071: libiberty-infinite-recursion-fix-2-of-2.patch + +Patch072: libiberty-infinite-recursion-fix-3-of-3.patch + diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include index 56e7473..b02efe8 100644 --- a/_gdb.spec.patch.include +++ b/_gdb.spec.patch.include @@ -69,3 +69,4 @@ %patch069 -p1 %patch070 -p1 %patch071 -p1 +%patch072 -p1 diff --git a/_patch_order b/_patch_order index 49e8ddc..a88e280 100644 --- a/_patch_order +++ b/_patch_order @@ -69,3 +69,4 @@ gdb-backport-call-check_typedef-at-beginning-of-dwarf_expr_context.patch gdb-rhbz2153228-fail-if-sh_info-is-zero.patch libiberty-infinite-recursion-fix-1-of-2.patch libiberty-infinite-recursion-fix-2-of-2.patch +libiberty-infinite-recursion-fix-3-of-3.patch diff --git a/gdb.spec b/gdb.spec index 5a5e5a1..fe10da5 100644 --- a/gdb.spec +++ b/gdb.spec @@ -73,7 +73,7 @@ Version: 12.1 # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL # Do not provide URL for snapshots as the file lasts there only for 2 days. @@ -1205,6 +1205,9 @@ fi %endif %changelog +* Mon Oct 30 2023 Guinevere Larsen - 12.1-5.el9 +- Fix issue introduced when backporting the recursion limit to the rust demangler. + * Tue Oct 10 2023 Guinevere Larsen - 12.1-4.el9 - Backport "Fix typo in recent code to add stack recursion limit to the Rust demangler." (Nick Clifton) diff --git a/libiberty-infinite-recursion-fix-3-of-3.patch b/libiberty-infinite-recursion-fix-3-of-3.patch new file mode 100644 index 0000000..9296677 --- /dev/null +++ b/libiberty-infinite-recursion-fix-3-of-3.patch @@ -0,0 +1,40 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Guinevere Larsen +Date: Mon, 30 Oct 2023 12:48:01 +0100 +Subject: libiberty-infinite-recursion-fix-3-of-3.patch + +fix backport error in patch 1 of this series. + +diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c +--- a/libiberty/rust-demangle.c ++++ b/libiberty/rust-demangle.c +@@ -1082,6 +1082,18 @@ demangle_path_maybe_open_generics (struct rust_demangler *rdm) + if (rdm->errored) + return open; + ++ if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ++ { ++ ++ rdm ->recursion; ++ if (rdm->recursion > RUST_MAX_RECURSION_COUNT) ++ { ++ /* FIXME: there ought to be a way to report ++ that the recorsion limit has been reached. */ ++ rdm->errored = 1; ++ goto end_of_func; ++ } ++ } ++ + if (eat (rdm, 'B')) + { + backref = parse_integer_62 (rdm); +@@ -1107,6 +1119,10 @@ demangle_path_maybe_open_generics (struct rust_demangler *rdm) + } + else + demangle_path (rdm, 0); ++ end_of_func: ++ if (rdm->recursion != RUST_NO_RECURSION_LIMIT) ++ -- rdm->recursion; ++ + return open; + } +