From 5b5206e3eeeb791dd49dfd0424e63cfaed0f3b3c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 5 Sep 2024 19:51:01 -0400 Subject: sci-mathematics/giac: add patch to fix GLIBCXX_ASSERTIONS crash Closes: https://github.com/gentoo/gentoo/pull/38241 Signed-off-by: Michael Orlitzky --- .../giac-1.9.0.995-fix-undefined-behavior.patch | 43 ++++++++++++++++++++++ sci-mathematics/giac/giac-1.9.0.995.ebuild | 1 + 2 files changed, 44 insertions(+) create mode 100644 sci-mathematics/giac/files/giac-1.9.0.995-fix-undefined-behavior.patch (limited to 'sci-mathematics') diff --git a/sci-mathematics/giac/files/giac-1.9.0.995-fix-undefined-behavior.patch b/sci-mathematics/giac/files/giac-1.9.0.995-fix-undefined-behavior.patch new file mode 100644 index 000000000000..92d37ae93fa8 --- /dev/null +++ b/sci-mathematics/giac/files/giac-1.9.0.995-fix-undefined-behavior.patch @@ -0,0 +1,43 @@ +From 864ecde569ce9fad636abe1135de33fdc94e6981 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky +Date: Thu, 5 Sep 2024 19:49:07 -0400 +Subject: [PATCH 1/1] src/vecteur.cc: skip undefined behavior with a bounds + check + +--- + src/vecteur.cc | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/vecteur.cc b/src/vecteur.cc +index de10197..119d454 100644 +--- a/src/vecteur.cc ++++ b/src/vecteur.cc +@@ -8490,6 +8490,17 @@ namespace giac { + } + else { + int C=col+1; ++ // mjo: C can be equal to cmax here, which makes buffer[C] ++ // illegal. In that case, however, nothing will happen ++ // below: ++ // ++ // 1. C = cmax ==> C >= (cmax-4), so the "for" loop is skipped ++ // 2. After the "for" loop, C += ptr-&buffer[C] sets C to zero ++ // 3. Now C = cmax means that the second "for" loop is skipped ++ // ++ // As a result, we can comment out this whole thing when ++ // C = cmax to avoid a crash. ++ if (C < cmax) { + longlong * ptr= &buffer[C],*ptrend=&buffer[0]+cmax-4; + const int *ptrN=&Nline[C]; + for (;ptr