Do not build surfex for i686 (rhbz#2104103)

- Add patches to fix code errors: -sequence-point, -array-compare,
  -use-after-free, -format-specifier, -type-mismatch
- Add -endian patch to fix oddities on s390x
This commit is contained in:
Jerry James 2022-07-25 17:18:22 -06:00
parent cfed2538f9
commit 05d12a0448
7 changed files with 411 additions and 4 deletions

View File

@ -0,0 +1,63 @@
Fix these warnings:
In file included from mpr_complex.cc:18:
../coeffs/longrat.h: In function 'BOOLEAN nlIsInteger(number, coeffs)':
../coeffs/coeffs.h:714:22: warning: statement has no effect [-Wunused-value]
714 | #define n_Test(a,r) 1
| ^
../coeffs/longrat.h:97:3: note: in expansion of macro 'n_Test'
97 | n_Test(q, r);
| ^~~~~~
mpr_complex.cc: In function 'bool operator>(const gmp_float&, const gmp_float&)':
mpr_complex.cc:290:11: warning: comparison between two arrays [-Warray-compare]
290 | if (a.t == b.t)
| ~~~~^~~~~~
mpr_complex.cc:290:11: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl<declaration error>[0] == &'component_ref' not supported by dump_decl<declaration error>[0]' to compare the addresses
mpr_complex.cc: In function 'bool operator<(const gmp_float&, const gmp_float&)':
mpr_complex.cc:296:11: warning: comparison between two arrays [-Warray-compare]
296 | if (a.t == b.t)
| ~~~~^~~~~~
mpr_complex.cc:296:11: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl<declaration error>[0] == &'component_ref' not supported by dump_decl<declaration error>[0]' to compare the addresses
mpr_complex.cc: In function 'bool operator>=(const gmp_float&, const gmp_float&)':
mpr_complex.cc:302:11: warning: comparison between two arrays [-Warray-compare]
302 | if (a.t == b.t)
| ~~~~^~~~~~
mpr_complex.cc:302:11: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl<declaration error>[0] == &'component_ref' not supported by dump_decl<declaration error>[0]' to compare the addresses
mpr_complex.cc: In function 'bool operator<=(const gmp_float&, const gmp_float&)':
mpr_complex.cc:308:11: warning: comparison between two arrays [-Warray-compare]
308 | if (a.t == b.t)
| ~~~~^~~~~~
mpr_complex.cc:308:11: note: use unary '+' which decays operands to pointers or '&'component_ref' not supported by dump_decl<declaration error>[0] == &'component_ref' not supported by dump_decl<declaration error>[0]' to compare the addresses
--- Singular-Release-4-2-1p3/libpolys/coeffs/mpr_complex.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/libpolys/coeffs/mpr_complex.cc 2022-07-25 10:49:45.733632538 -0600
@@ -287,25 +287,25 @@ bool gmp_float::isMOne() const
}
bool operator > ( const gmp_float & a, const gmp_float & b )
{
- if (a.t == b.t)
+ if (&a.t == &b.t)
return false;
return mpf_cmp( a.t, b.t ) > 0;
}
bool operator < ( const gmp_float & a, const gmp_float & b )
{
- if (a.t == b.t)
+ if (&a.t == &b.t)
return false;
return mpf_cmp( a.t, b.t ) < 0;
}
bool operator >= ( const gmp_float & a, const gmp_float & b )
{
- if (a.t == b.t)
+ if (&a.t == &b.t)
return true;
return mpf_cmp( a.t, b.t ) >= 0;
}
bool operator <= ( const gmp_float & a, const gmp_float & b )
{
- if (a.t == b.t)
+ if (&a.t == &b.t)
return true;
return mpf_cmp( a.t, b.t ) <= 0;
}

92
Singular-endian.patch Normal file
View File

@ -0,0 +1,92 @@
--- Singular-Release-4-2-1p3/Singular/idrec.h.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/Singular/idrec.h 2022-07-23 08:10:08.908714052 -0600
@@ -44,7 +44,6 @@ class idrec
short lev;
short ref;
- unsigned long id_i;
idrec() { memset(this,0,sizeof(*this)); }
inline void Init() { memset(this,0,sizeof(*this)); }
--- Singular-Release-4-2-1p3/Singular/ipid.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/Singular/ipid.cc 2022-07-23 08:55:42.510852256 -0600
@@ -62,38 +62,23 @@ void paCleanUp(package pack);
/*0 implementation*/
-static inline long iiS2I(const char *s)
-{
- long l;
- strncpy((char*)&l,s,SIZEOF_LONG);
- return l;
-}
-
idhdl idrec::get(const char * s, int level)
{
assume(s!=NULL);
assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
idhdl h = this;
idhdl found=NULL;
- int l;
- const char *id_;
- unsigned long i=iiS2I(s);
- char *dummy=(char*)&i;
- BOOLEAN less4=(dummy[SIZEOF_LONG-1]=='\0');
while (h!=NULL)
{
- omCheckAddr((ADDRESS)IDID(h));
- l=IDLEV(h);
+ const char *id_=IDID(h);
+ omCheckAddr((ADDRESS)id_);
+ int l=IDLEV(h);
if ((l==0)||(l==level))
{
- if (i==h->id_i)
+ if (0 == strcmp(s, id_))
{
- id_=IDID(h);
- if (less4 || (0 == strcmp(s+SIZEOF_LONG,id_+SIZEOF_LONG)))
- {
- if(l==level) return h;
- found=h;
- }
+ if(l==level) return h;
+ found=h;
}
}
h = IDNEXT(h);
@@ -106,21 +91,14 @@ idhdl idrec::get_level(const char * s, i
assume(s!=NULL);
assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
idhdl h = this;
- int l;
- const char *id_;
- unsigned long i=iiS2I(s);
- int less4=(i < (1L<<((SIZEOF_LONG-1)*8)));
while (h!=NULL)
{
- omCheckAddr((ADDRESS)IDID(h));
- l=IDLEV(h);
- if ((l==level)&&(i==h->id_i))
+ const char *id_=IDID(h);
+ omCheckAddr((ADDRESS)id_);
+ int l=IDLEV(h);
+ if ((l==level)&&(0 == strcmp(s, id_)))
{
- id_=IDID(h);
- if (less4 || (0 == strcmp(s+SIZEOF_LONG,id_+SIZEOF_LONG)))
- {
- return h;
- }
+ return h;
}
h = IDNEXT(h);
}
@@ -243,7 +221,6 @@ idhdl idrec::set(const char * s, int lev
IDLEV(h) = level;
IDNEXT(h) = this;
BOOLEAN at_start=(this==IDROOT);
- h->id_i=iiS2I(s);
if (t==BUCKET_CMD) WarnS("defining polyBucket");
if (init)
{

View File

@ -0,0 +1,28 @@
--- Singular-Release-4-2-1p3/kernel/oswrapper/vspace.cc.orig 2022-03-03 16:09:04.971209163 -0700
+++ Singular-Release-4-2-1p3/kernel/oswrapper/vspace.cc 2022-07-25 13:13:02.041950315 -0600
@@ -725,10 +725,10 @@ static void print_freelists() {
for (int i = 0; i <= LOG2_SEGMENT_SIZE; i++) {
vaddr_t vaddr = vmem.freelist[i];
if (vaddr != VADDR_NULL) {
- std::printf("%2d: %ld", i, vaddr);
+ std::printf("%2d: %zu", i, vaddr);
vaddr_t prev = block_ptr(vaddr)->prev;
if (prev != VADDR_NULL) {
- std::printf("(%ld)", prev);
+ std::printf("(%zu)", prev);
}
assert(block_ptr(vaddr)->prev == VADDR_NULL);
for (;;) {
@@ -737,10 +737,10 @@ static void print_freelists() {
vaddr = block->next;
if (vaddr == VADDR_NULL)
break;
- std::printf(" -> %ld", vaddr);
+ std::printf(" -> %zu", vaddr);
vaddr_t prev = block_ptr(vaddr)->prev;
if (prev != last_vaddr) {
- std::printf("(%ld)", prev);
+ std::printf("(%zu)", prev);
}
}
std::printf("\n");

View File

@ -0,0 +1,17 @@
Fix this warning:
gfanlib_tropicalhomotopy.h:457:83: warning: operation on 'numberToDrop' may be undefined [-Wsequence-point]
457 | int numberToDrop=(subconfigurationIndex!=0) ? numberToDrop=k+1 : 0;
| ~~~~~~~~~~~~^~~~
--- Singular-Release-4-2-1p3/gfanlib/gfanlib_tropicalhomotopy.h.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/gfanlib/gfanlib_tropicalhomotopy.h 2022-07-25 10:34:15.834633612 -0600
@@ -454,7 +454,7 @@ template<class mvtyp, class mvtypDouble,
//chioices are "relative" so no update is needed.
choices=parent.choices;
- int numberToDrop=(subconfigurationIndex!=0) ? numberToDrop=k+1 : 0;
+ int numberToDrop=(subconfigurationIndex!=0) ? k+1 : 0;
choices[subconfigurationIndex-1].first-=numberToDrop;
choices[subconfigurationIndex-1].second-=numberToDrop;

View File

@ -0,0 +1,11 @@
--- Singular-Release-4-2-1p3/kernel/groebner_walk/walkSupport.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/kernel/groebner_walk/walkSupport.cc 2022-07-25 13:16:57.297425786 -0600
@@ -12,7 +12,7 @@
#include "kernel/groebner_walk/walkSupport.h"
#include "kernel/GBEngine/kstd1.h"
-EXTERN_VAR BOOLEAN overflow_error;
+EXTERN_VAR int overflow_error;
///////////////////////////////////////////////////////////////////
//Support functions for Groebner Walk and Fractal Walk

View File

@ -0,0 +1,160 @@
Keep an object from being deallocated while pointers to or into it are in use.
Fixes warnings like these:
longrat.cc: In function 'nlMapC(snumber*, n_Procs_s*, n_Procs_s*)':
longrat.cc:599:13: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=]
599 | e=(*f)[0]._mp_exp-size;
| ~~~~~~~~^~~~~~~
longrat.cc:573:40: note: unnamed temporary defined here
573 | mpf_t *f = ((gmp_complex*)from)->real()._mpfp();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
longrat.cc:581:8: warning: using dangling pointer 'size_113' to an unnamed temporary [-Wdangling-pointer=]
581 | size = (*f)[0]._mp_size;
| ~~~~~^~~~~~~~~~~~~~~~~~
longrat.cc:573:40: note: unnamed temporary defined here
573 | mpf_t *f = ((gmp_complex*)from)->real()._mpfp();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
longrat.cc:592:6: warning: dangling pointer 'qp_115' to an unnamed temporary may be used [-Wdangling-pointer=]
592 | qp = (*f)[0]._mp_d;
| ~~~^~~~~~~~~~~~~~~
longrat.cc:573:40: note: unnamed temporary defined here
573 | mpf_t *f = ((gmp_complex*)from)->real()._mpfp();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
--- Singular-Release-4-2-1p3/factory/cfModGcd.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/factory/cfModGcd.cc 2022-07-25 14:53:41.944360644 -0600
@@ -1825,7 +1825,6 @@ gaussianElimFq (CFMatrix& M, CFArray& L,
#else
factoryError("NTL/FLINT missing: gaussianElimFq");
#endif
- delete N;
M= (*N) (1, M.rows(), 1, M.columns());
L= CFArray (M.rows());
--- Singular-Release-4-2-1p3/libpolys/coeffs/longrat.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/libpolys/coeffs/longrat.cc 2022-07-25 10:59:58.720085578 -0600
@@ -570,7 +570,8 @@ static number nlMapC(number from, const
return INT_TO_SR(0);
}
- mpf_t *f = ((gmp_complex*)from)->real()._mpfp();
+ gmp_float gfl = ((gmp_complex*)from)->real();
+ mpf_t *f = gfl._mpfp();
number res;
mpz_ptr dest,ndest;
--- Singular-Release-4-2-1p3/Singular/countedref.cc.orig 2021-12-17 11:35:18.000000000 -0700
+++ Singular-Release-4-2-1p3/Singular/countedref.cc 2022-07-25 14:51:02.519890787 -0600
@@ -317,13 +317,17 @@ public:
/// Recover the actual object from Singular interpreter object
static self cast(leftv arg) {
assume(arg != NULL); assume(is_ref(arg));
- return self::cast(arg->Data());
+ auto d = arg->Data();
+ return self::cast(d);
}
/// If necessary dereference.
static BOOLEAN resolve(leftv arg) {
assume(arg != NULL);
- while (is_ref(arg)) { if(CountedRef::cast(arg).dereference(arg)) return TRUE; };
+ while (is_ref(arg)) {
+ CountedRef ref = CountedRef::cast(arg);
+ if (ref.dereference(arg)) return TRUE;
+ }
return (arg->next != NULL) && resolve(arg->next);
}
@@ -369,8 +373,9 @@ char* countedref_String(blackbox */*b*/,
/// blackbox support - copy element
void* countedref_Copy(blackbox*/*b*/, void* ptr)
{
- if (ptr) return CountedRef::cast(ptr).outcast();
- return NULL;
+ if (!ptr) return NULL;
+ CountedRef ref = CountedRef::cast(ptr);
+ return ref.outcast();
}
/// blackbox support - assign element
@@ -383,12 +388,16 @@ BOOLEAN countedref_Assign(leftv result,
}
// Case: copy reference
- if (result->Typ() == arg->Typ())
- return CountedRef::cast(arg).outcast(result);
+ if (result->Typ() == arg->Typ()) {
+ CountedRef ref = CountedRef::cast(arg);
+ return ref.outcast(result);
+ }
// Case: new reference
- if ((arg->rtyp == IDHDL) || CountedRef::is_ref(arg))
- return CountedRef(arg).outcast(result);
+ if ((arg->rtyp == IDHDL) || CountedRef::is_ref(arg)) {
+ CountedRef ref(arg);
+ return ref.outcast(result);
+ }
WerrorS("Can only take reference from identifier");
return TRUE;
@@ -483,7 +492,10 @@ BOOLEAN countedref_Op3(int op, leftv res
/// blackbox support - destruction
void countedref_destroy(blackbox */*b*/, void* ptr)
{
- if (ptr) CountedRef::cast(ptr).destruct();
+ if (ptr) {
+ CountedRef ref = CountedRef::cast(ptr);
+ ref.destruct();
+ }
}
@@ -539,7 +551,8 @@ public:
/// Blackbox support - generate initialized, but all-zero - shared data
void* countedref_InitShared(blackbox*)
{
- return CountedRefShared().outcast();
+ auto ref = CountedRefShared();
+ return ref.outcast();
}
/// Blackbox support - unary operation for shared data
@@ -656,23 +669,31 @@ BOOLEAN countedref_AssignShared(leftv re
/// Case: new reference to already shared data
if (result->Typ() == arg->Typ())
{
- if (result->Data() != NULL)
- CountedRefShared::cast(result).destruct();
- return CountedRefShared::cast(arg).outcast(result);
+ if (result->Data() != NULL) {
+ CountedRefShared ref = CountedRefShared::cast(result);
+ ref.destruct();
+ }
+ CountedRefShared ref = CountedRefShared::cast(arg);
+ return ref.outcast(result);
}
if(CountedRefShared::cast(result).unassigned())
{
- return CountedRefShared::cast(result).assign(result, arg);
+ CountedRefShared ref = CountedRefShared::cast(result);
+ return ref.assign(result, arg);
}
/// Case: new shared data
- return CountedRefShared(arg).outcast(result);
+ CountedRefShared ref(arg);
+ return ref.outcast(result);
}
/// blackbox support - destruction
void countedref_destroyShared(blackbox */*b*/, void* ptr)
{
- if (ptr) CountedRefShared::cast(ptr).destruct();
+ if (ptr) {
+ CountedRefShared ref = CountedRefShared::cast(ptr);
+ ref.destruct();
+ }
}

View File

@ -56,8 +56,10 @@ BuildRequires: gcc-c++
BuildRequires: gfan
BuildRequires: gmp-devel
BuildRequires: graphviz
%ifarch %{java_arches}
BuildRequires: java-devel
BuildRequires: javapackages-tools
%endif
BuildRequires: libgfan-devel
BuildRequires: libnormaliz-devel
BuildRequires: libtool
@ -116,6 +118,18 @@ Patch8: %{name}-emacs.patch
Patch9: %{name}-javac.patch
# Adapt to GCC 12
Patch10: %{name}-gcc12.patch
# Fix a sequence point error
Patch11: %{name}-sequence-point.patch
# Avoid an unnecessary array comparison
Patch12: %{name}-array-compare.patch
# Fix several "use after free" scenarios due to temporary objects
Patch13: %{name}-use-after-free.patch
# Fix some incorrect format specifiers
Patch14: %{name}-format-specifier.patch
# Fix mismatched type declarations
Patch15: %{name}-type-mismatch.patch
# Change little-endian-specific code to endian-agnostic code
Patch16: %{name}-endian.patch
%description
Singular is a computer algebra system for polynomial computations, with
@ -198,6 +212,7 @@ Requires: flint-devel%{?_isa}
%description libpolys-devel
Development files for libpolys.
%ifarch %{java_arches}
%package surfex
Summary: Singular java interface
Requires: java
@ -205,6 +220,7 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%description surfex
This package contains the Singular java interface.
%endif
%prep
@ -222,20 +238,23 @@ sed -i 's/-std=c++11//' m4/ntl-check.m4
# Regenerate configure due to patches 0, 1, and 6
autoreconf -fi
# The file countedref.cc needs to be built without strict aliasing
sed -i '/countedref\.cc/s/\$(CXXFLAGS)/& -fno-strict-aliasing/g' Singular/Makefile.in
# Do not use the prebuilt surfex.jar
rm -f Singular/LIB/surfex/surfex.jar
%build
export CPPFLAGS="-I%{_includedir}/flint -I%{_includedir}/gfanlib"
export CPPFLAGS='-I%{_includedir}/flint -I%{_includedir}/gfanlib'
%if %{with python}
pyincdir=$(python2 -Esc "import sysconfig; print(sysconfig.get_paths()['include'])")
CPPFLAGS="$CPPFLAGS -I$pyincdir"
%endif
export CFLAGS="%{build_cflags} -fPIC -fno-delete-null-pointer-checks"
export CXXFLAGS="%{build_cxxflags} -fPIC -fno-delete-null-pointer-checks"
export CFLAGS='%{build_cflags} -fPIC'
export CXXFLAGS='%{build_cxxflags} -fPIC'
# Cannot use RPM_LD_FLAGS, as -Wl,-z,now breaks lazy module loading
export LDFLAGS="-Wl,--as-needed -Wl,-z,relro"
export LDFLAGS='-Wl,--as-needed -Wl,-z,relro'
module load 4ti2-%{_arch}
module load lrcalc-%{_arch}
@ -279,9 +298,12 @@ module load lrcalc-%{_arch}
make -C doc -j1 -f Makefile-docbuild singular.idx
make -C doc -j1 all-local
%endif
%ifarch %{java_arches}
pushd Singular/LIB/surfex
./make_surfex
popd
%endif
%install
%make_install
@ -290,9 +312,11 @@ popd
rm -fr %{buildroot}%{_includedir}/gfanlib
rm -f %{buildroot}%{_libdir}/libgfan*
%ifarch %{java_arches}
# Install surfex.jar
mkdir %{buildroot}%{_datadir}/singular/LIB/surfex
cp -p Singular/LIB/surfex/surfex.jar %{buildroot}%{_datadir}/singular/LIB/surfex
%endif
# Validate the desktop files
desktop-file-validate %{buildroot}%{_datadir}/applications/Singular.desktop
@ -351,6 +375,7 @@ exec %{singulardir}/TSingular --singular %{_bindir}/Singular "\$@"
EOF
chmod 0755 %{buildroot}%{_bindir}/TSingular
%ifarch %{java_arches}
# surfex
cat > %{buildroot}%{_bindir}/surfex << EOF
#!/bin/sh
@ -360,6 +385,7 @@ module load surf-geometry-%{_arch}
exec %{singulardir}/surfex %{singulardir}/LIB/surfex "\$@"
EOF
chmod 0755 %{buildroot}%{_bindir}/surfex
%endif
# ESingular
cat > %{buildroot}%{_bindir}/ESingular << EOF
@ -414,8 +440,10 @@ make check
%{_libexecdir}/singular/
%dir %{_datadir}/singular/
%{_datadir}/singular/LIB/
%ifarch %{java_arches}
%exclude %{_datadir}/singular/LIB/surfex.lib
%exclude %{_datadir}/singular/LIB/surfex
%endif
%files devel
%{_bindir}/libsingular-config
@ -441,10 +469,12 @@ make check
%{_datadir}/singular/emacs/
%{singulardir}/ESingular
%ifarch %{java_arches}
%files surfex
%{_bindir}/surfex
%{_datadir}/singular/LIB/surfex.lib
%{_datadir}/singular/LIB/surfex/
%endif
%files -n factory
%license factory/COPYING
@ -486,6 +516,12 @@ make check
%changelog
* Mon Jul 25 2022 Jerry James <loganjerry@gmail.com> - 4.2.1p3-3
- Do not build surfex for i686 (rhbz#2104103)
- Add patches to fix code errors: -sequence-point, -array-compare,
-use-after-free, -format-specifier, -type-mismatch
- Add -endian patch to fix oddities on s390x
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.1p3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild