diff options
author | Michael Orlitzky <mjo@gentoo.org> | 2024-09-05 19:51:01 -0400 |
---|---|---|
committer | Michael Orlitzky <mjo@gentoo.org> | 2024-09-05 19:51:01 -0400 |
commit | 5b5206e3eeeb791dd49dfd0424e63cfaed0f3b3c (patch) | |
tree | 5a203e2e82692755ece98d41adf4eff02b3aaafc /sci-mathematics | |
parent | sci-mathematics/giac: Update glibcxx assertion patch for a more complete cove... (diff) | |
download | gentoo-5b5206e3eeeb791dd49dfd0424e63cfaed0f3b3c.tar.gz gentoo-5b5206e3eeeb791dd49dfd0424e63cfaed0f3b3c.tar.bz2 gentoo-5b5206e3eeeb791dd49dfd0424e63cfaed0f3b3c.zip |
sci-mathematics/giac: add patch to fix GLIBCXX_ASSERTIONS crash
Closes: https://github.com/gentoo/gentoo/pull/38241
Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
Diffstat (limited to 'sci-mathematics')
-rw-r--r-- | sci-mathematics/giac/files/giac-1.9.0.995-fix-undefined-behavior.patch | 43 | ||||
-rw-r--r-- | sci-mathematics/giac/giac-1.9.0.995.ebuild | 1 |
2 files changed, 44 insertions, 0 deletions
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 <michael@orlitzky.com> +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<ptrend;ptrN+=4,ptr+=4){ +@@ -8502,6 +8513,7 @@ namespace giac { + for (;C<cmax;++C){ + buffer[C] -= coeff*Nline[C]; + } ++ } + } + } + // copy back buffer to N[l] +-- +2.44.2 + diff --git a/sci-mathematics/giac/giac-1.9.0.995.ebuild b/sci-mathematics/giac/giac-1.9.0.995.ebuild index 32f7faec217b..28dba8596875 100644 --- a/sci-mathematics/giac/giac-1.9.0.995.ebuild +++ b/sci-mathematics/giac/giac-1.9.0.995.ebuild @@ -59,6 +59,7 @@ PATCHES=( "${FILESDIR}/${PN}-1.9.0.21-pari-2.15.patch" "${FILESDIR}/${PN}-1.9.0.67-system-gl2ps.patch" "${FILESDIR}/${P}-glibcxx-assertions.patch" + "${FILESDIR}/${P}-fix-undefined-behavior.patch" ) REQUIRED_USE="test? ( gui )" |