Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

pseudoRemainder sometimes segfaults on ppc64el #1692

Closed d-torrance closed 3 years ago

d-torrance commented 3 years ago

Running a build of the release-17 branch in a ppc64el Debian unstable chroot using qemu:

Macaulay2, version 1.16.99
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems,
               LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra,
               Saturation, TangentCone

i1 : A = ZZ[a, b];

i2 : pseudoRemainder(3*a^3-a*b-4, 5*a-b)
-- SIGSEGV
-* stack trace, pid: 2640714
 0# 0x000000400010CA7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 1# 0x000000400010CE7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 2# 0x000000400D5D77E0
-- end stack trace *-

(Why isn't Boost giving us a nice stacktrace?)

But I can't reproduce the issue reliably. A moment later:

Macaulay2, version 1.16.99
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems,
               LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra,
               Saturation, TangentCone

i1 : A = ZZ[a,b];

i2 : pseudoRemainder(3*a^3-a*b-4, 5*a-b)

       3      2
o2 = 3b  - 25b  - 500

o2 : A
d-torrance commented 3 years ago

Another segfault with the same addresses is showing up in Dmodules:

Macaulay2, version 1.16.99
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems,
               LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra,
               Saturation, TangentCone

i1 : needsPackage "Dmodules";

i2 : D4 = makeWA(QQ[x_1..x_4]);

i3 : H = sub(gkz(matrix{{1,1,1,1},{0,1,3,4}},{1,2}), vars D4);

o3 : Ideal of D4

i4 : singLocus H
-- SIGSEGV
-* stack trace, pid: 2736062
 0# 0x000000400010CA7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 1# 0x000000400010CE7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 2# 0x000000400CDCC6E0
-- end stack trace *-
d-torrance commented 3 years ago

And again in IntegralClosure:

root@peg-amy:/build/macaulay2-1.16.0.2+git1111.c9b654a+ds# cat M2/usr-dist/common/share/doc/Macaulay2/IntegralClosure/example-output/_integral__Closure_lp__Ideal_cm__Ring__Element_cm__Z__Z_rp.errors
-- -*- M2-comint -*- hash: -696033314

i1 : S = ZZ/32003[a,b,c];

i2 : F = a^2*b^2*c+a^3+b^3+c^3

      2 2     3    3    3
o2 = a b c + a  + b  + c

o2 : S

i3 : J = ideal jacobian ideal F

                2      2    2        2   2 2     2
o3 = ideal (2a*b c + 3a , 2a b*c + 3b , a b  + 3c )

o3 : Ideal of S

i4 : time integralClosure J
-- SIGSEGV
-* stack trace, pid: 2752450
 0# 0x000000400010CA7C in /build/macaulay2-1.16.0.2+git1111.c9b654a+ds/M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 1# 0x000000400010CE7C in /build/macaulay2-1.16.0.2+git1111.c9b654a+ds/M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 2# 0x000000400CDCD730
-- end stack trace *-
mikestillman commented 3 years ago

I need to look at what this could possibly be, but my first guess is that it is related to factory (which is where the pseudoRemainder code is coming from).

d-torrance commented 3 years ago

I need to look at what this could possibly be, but my first guess is that it is related to factory (which is where the pseudoRemainder code is coming from).

Yeah, that looks to be the case. I dug a little deeper into the next segfault I ran across, in HyperplaneArrangements:

root@peg-amy:/build/macaulay2-1.16.0.2+git1111.c9b654a+ds# cat M2/usr-dist/common/share/doc/Macaulay2/HyperplaneArrangements/example-output/_lct.errors
-- -*- M2-comint -*- hash: -499634077

i1 : R := QQ[x,y,z];

i2 : A := arrangement ((x^2 - y^2)*(x^2 - z^2)*(y^2 - z^2)*z);
-- SIGSEGV
-* stack trace, pid: 2767312
 0# 0x000000400010CA7C in /build/macaulay2-1.16.0.2+git1111.c9b654a+ds/M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 1# 0x000000400010CE7C in /build/macaulay2-1.16.0.2+git1111.c9b654a+ds/M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 2# 0x000000400D5D7F10
-- end stack trace *-

Looking at the code for arrangement:

https://github.com/Macaulay2/M2/blob/1a01f368e88857a0516858f968cad2cd23a05a49/M2/Macaulay2/packages/HyperplaneArrangements.m2#L122-L124

And sure enough:

Macaulay2, version 1.16.99
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems,
               LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra,
               Saturation, TangentCone

i1 : R = QQ[x,y,z]; 

i2 : factor((x^2 - y^2)*(x^2 - z^2)*(y^2 - z^2)*z)
-- SIGSEGV
-* stack trace, pid: 2782934
 0# 0x000000400010CA7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 1# 0x000000400010CE7C in M2/usr-dist/powerpc64le-Linux-Debian-unstable/bin/M2-binary
 2# 0x000000400CDD76A0
-- end stack trace *-
DanGrayson commented 3 years ago

Can you arrange to keep the symbol table and find out what's at those addresses? (The high nonzero bit probably indicates it's in a sharable library.)

d-torrance commented 3 years ago

Hrm -- previous PPA builds on ppc64el have already gotten past these examples without any problems. I'm assuming that Canonical has actual machines with this architecture and isn't just emulating them! Maybe this is just a qemu bug...

https://launchpadlibrarian.net/510941465/buildlog_ubuntu-groovy-ppc64el.macaulay2_1.16.0.2+git202012111652-0ppa202012101516~ubuntu20.10.1_BUILDING.txt.gz

d-torrance commented 3 years ago

Macaulay2 is building just fine on ppc64el in Ubuntu 21.04. The only difference I can think of is that the Ubuntu singular package has been rebuilt against flint 2.6.3, but the Debian package has not. So I don't think this is a Macaulay2 bug. Closing.