sagemath / giac

Fork of https://salsa.debian.org/science-team/giac for the purpose of tracking the upstream Giac sources at http://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source – branch sagemath adds integration testing with SageMath on GH Actions
GNU General Public License v3.0
1 stars 0 forks source link

Update to 1.9.0.57 #1

Open orlitzky opened 1 year ago

orlitzky commented 1 year ago

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

From fc0fb5ba02953d6e15424ce3a2d8f5b52380ffb4 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
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 <michael@orlitzky.com>
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 commented 1 year ago

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 commented 1 year ago

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.