Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.9.0.57 #1

Open
orlitzky opened this issue Aug 26, 2023 · 2 comments
Open

Update to 1.9.0.57 #1

orlitzky opened this issue Aug 26, 2023 · 2 comments

Comments

@orlitzky
Copy link

A reminder for whenever. The Debian repo is up to 1.9.0.57 now, and I've got two patches for it (from sagemath/sage#35745) when we update:

From fc0fb5ba02953d6e15424ce3a2d8f5b52380ffb4 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <[email protected]>
Date: Sun, 25 Jun 2023 13:43:35 -0400
Subject: [PATCH 1/1] src/vecteur.cc: fix invalid vector indexing.

A few places in vector.cc use the construct &buffer[n]-m where
"buffer" is an std::vector and "n" its size. This is undefined
behavior since the index is outside of the allowed range (0 through
n-1). With GLIBCXX_ASSERTIONS enabled, it crashes on the out-of-
bounds index.

The most obvious fix is to use &buffer[n-1]-(m+1), which avoids the
issue so long as n >= 1. I think this will always be the case in the
affected code, but if I'm wrong, it can be fixed by adding a special
case for n == 0.
---
 src/vecteur.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/vecteur.cc b/src/vecteur.cc
index 89b1445..c91af66 100644
--- a/src/vecteur.cc
+++ b/src/vecteur.cc
@@ -7998,7 +7998,7 @@ namespace giac {
 	if (convertpos){
 	  int C=col+1;
 	  longlong * buf=&buffer[C];
-	  longlong * bufend=&buffer[cmax]-8;
+	  longlong * bufend=&buffer[cmax-1]-7;
 	  const int * nline=&Nline[C];
 	  for (;buf<=bufend;buf+=8,nline+=8){
 	    longlong x,y;
@@ -8022,7 +8022,7 @@ namespace giac {
 	else {
 	  int C=col+1;
 	  longlong * buf=&buffer[C];
-	  longlong * bufend=&buffer[cmax]-8;
+	  longlong * bufend=&buffer[cmax-1]-7;
 	  const int * nline=&Nline[C];
 	  for (;buf<=bufend;buf+=8,nline+=8){
 	    buf[0] -= coeff*nline[0];
@@ -8268,7 +8268,7 @@ namespace giac {
 	    }
 #else
 	    int C=col+1;
-	    longlong * ptr= &buffer[C],*ptrend=&buffer[cmax]-4;
+	    longlong * ptr= &buffer[C],*ptrend=&buffer[cmax-1]-3;
 	    const int *ptrN=&Nline[C];
 	    for (;ptr<ptrend;ptrN+=4,ptr+=4){
 	      longlong x = *ptr;
@@ -8300,7 +8300,7 @@ namespace giac {
 	  }
 	  else {
 	    int C=col+1;
-	    longlong * ptr= &buffer[C],*ptrend=&buffer[cmax]-4;
+	    longlong * ptr= &buffer[C],*ptrend=&buffer[cmax-1] - 3;
 	    const int *ptrN=&Nline[C];
 	    for (;ptr<ptrend;ptrN+=4,ptr+=4){
 	      *ptr -= coeff*(*ptrN);
-- 
2.39.3
From 8fa2b53ee0db1827a4ddd88a7e754a7b1d91ca2c Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <[email protected]>
Date: Fri, 25 Aug 2023 20:33:31 -0400
Subject: [PATCH 1/1] configure.ac: delete _GLIBCXX_ASSERTIONS override

This was added upstream when it was pointed out that the codebase
contains undefined behavior that triggers glibcxx's assertions.
Disabling the assertions without fixing the undefined behavior is not
a satisfactory solution, so we drop the override.
---
 configure.ac | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index d66c3e1..6fef28b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,10 +45,6 @@ GINAC_STD_CXX_HEADERS
 AC_CHECK_HEADERS(regex)
 AC_CHECK_FUNCS(tgammaf)
 
-dnl CXXFLAGS="$CXXFLAGS -std=c++0x"
-dnl avoid "security" checks for vectors
-CXXFLAGS="$CXXFLAGS -U_GLIBCXX_ASSERTIONS"
-
 dnl Define DOUBLEVAL if bigendian
 if test "x$ac_cv_c_bigendian" = "xyes"; then
 	CXXFLAGS="$CXXFLAGS -DDOUBLEVAL"
-- 
2.41.0
@mkoeppe
Copy link

mkoeppe commented Aug 28, 2023

I have updated the repo.
Doesn't work quite yet because our old spkg-src script (from which now sage/spkg-src is derived) kept some distributable bits of the French documentation directory, whereas the Debian repo removes the directory altogether.

PRs or direct pushes to the sagemath branch are welcome

@orlitzky
Copy link
Author

The french docs are a problem because the README says,

The French documentation is not released under the GPL. It is (c)
by Renee de Graeve. It can be freely distributed for non commercial purpose. Other kind of redistributions require the consent of the copyright holder.

That's not very clear as to what you can do with it... are we allowed to host it here if we ultimately distribute it to someone who uses it commercially? Rather than play lawyer I've refused to redistribute the giac sources on the Gentoo mirrors as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants