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

check(30, "AssociativeAlgebras") segfaulting on armhf #1903

Open d-torrance opened 3 years ago

d-torrance commented 3 years ago

From a PPA build of the development branch in Ubuntu 21.04 on armhf:

-- running   check(30, "AssociativeAlgebras")                              
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-17198-0/39-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/<<BUILDDIR>>/macaulay2-1.17.2.1+git202101300204/M2/usr-dist/arm-Linux-Ubuntu-21.04/bin/M2-binary" -q --int --no-randomize --no-readline --silent --stop --print-width 129 -e 'needsPackage("AssociativeAlgebras",Reload=>true,FileName=>"/<<BUILDDIR>>/macaulay2-1.17.2.1+git202101300204/M2/Macaulay2/packages/AssociativeAlgebras.m2")' <"/tmp/M2-17198-0/38.m2" >>"/tmp/M2-17198-0/38.tmp" 2>&1
/tmp/M2-17198-0/38.tmp:0:1: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-17198-0/38.m2:0:1: (input file)
M2: *** Error 1
 -- 1.68003 seconds elapsed
 -- running   check(31, "AssociativeAlgebras")                               -- 1.05338 seconds elapsed
 -- running   check(32, "AssociativeAlgebras")                               -- 3.35071 seconds elapsed
 -- running   check(33, "AssociativeAlgebras")                               -- 1.01143 seconds elapsed
AssociativeAlgebras/tests.m2:1073:1: error:
 -- o23 : RingMap S <--- kk <|z , z , z , y , y , y |>
 --                            1   2   3   1   2   3
 -- 
 -- i24 : assert(alpha(preim) == alpha(z_1^2*z_2^3*z_3))
 -- -- SIGSEGV
 -- -* stack trace, pid: 17507
 --  0# stack_trace(std::ostream&, bool) at ./M2/Macaulay2/d/main.cpp:124
 --  1# segv_handler at ./M2/Macaulay2/d/main.cpp:240
 --  2# 0xF69881B0 in /lib/arm-linux-gnueabihf/libc.so.6
 -- -- end stack trace *-
 -- 
../m2/debugging.m2:20:6:(1):[9]: error: test(s) #30 of package AssociativeAlgebras failed.
../m2/testing.m2:97:9:(1):[8]: --back trace--
mikestillman commented 3 years ago

@d-torrance These are all good crashes/bugs/compile issues you are finding!

d-torrance commented 3 years ago

This just happened on a GitHub autotools-ubuntu-20.04-default build too: https://github.com/Macaulay2/M2/pull/1908/checks?check_run_id=1803950169

No segfault this time, but the test failed.

d-torrance commented 3 years ago

A little more informative stack trace from this Github build:

/home/runner/work/M2/M2/M2/Macaulay2/packages/AssociativeAlgebras/tests.m2:1136:1-1172:1: error:
 -- i23 : alpha = map(S,ring graphPhi,gens S | {f_1,f_2,f_3})
 -- 
 -- o23 = map (S, kk <|z , z , z , y , y , y |>, {z , z , z , z  + z  + z , z  + (- x - 1)z  + x*z , z  + x*z  + (- x - 1)z , x})
 --                     1   2   3   1   2   3      1   2   3   1    2    3   1             2      3   1      2             3
 -- 
 -- o23 : RingMap S <--- kk <|z , z , z , y , y , y |>
 --                            1   2   3   1   2   3
 -- 
 -- i24 : assert(alpha(preim) == alpha(z_1^2*z_2^3*z_3))
 -- -- SIGSEGV
 -- -* stack trace, pid: 129683
 --  0# stack_trace(std::ostream&, bool) at ../../Macaulay2/bin/main.cpp:124
 --  1# segv_handler at ../../Macaulay2/bin/main.cpp:240
 --  2# 0x00007F5CC662D210 in /lib/x86_64-linux-gnu/libc.so.6
 --  3# GC_generic_malloc_many in /lib/x86_64-linux-gnu/libgc.so.1
 --  4# GC_malloc_kind in /lib/x86_64-linux-gnu/libgc.so.1
 --  5# getmem at ../../Macaulay2/d/M2mem.c:48
 --  6# M2::ConcreteRing<M2::ARingQQGMP>::copy(ring_elem) const at ../../Macaulay2/e/aring-glue.hpp:280
 --  7# PolyRing::copy(ring_elem) const at ../../Macaulay2/e/poly.cpp:648
 --  8# PolyRing::add(ring_elem, ring_elem) const at ../../Macaulay2/e/poly.cpp:757
 --  9# Ring::add_to(ring_elem&, ring_elem&) const at ../../Macaulay2/e/ring.cpp:186
 -- 10# PolyRing::mult(ring_elem, ring_elem) const at ../../Macaulay2/e/poly.cpp:818
 -- 11# PolyRingQuotient::mult(ring_elem, ring_elem) const at ../../Macaulay2/e/polyquotient.hpp:164
 -- 12# FreeAlgebra::mult_by_term_left_and_right(Polynomial<CoefficientRingType>&, Polynomial<CoefficientRingType> const&, ring_elem, Monom, Monom) const at ../../Macaulay2/e/NCAlgebras/FreeAlgebra.cpp:607
 -- 13# FreeAlgebra::mult_by_term_left_and_right(Polynomial<CoefficientRingType>&, Polynomial<CoefficientRingType> const&, ring_elem, Word const&, Word const&) const at ../../Macaulay2/e/NCAlgebras/FreeAlgebra.cpp:642
 -- 14# NCGroebner::twoSidedReduction(Polynomial<CoefficientRingType> const*) const at ../../Macaulay2/e/NCAlgebras/NCGroebner.cpp:306
 -- 15# FreeAlgebraQuotient::mult(Polynomial<CoefficientRingType>&, Polynomial<CoefficientRingType> const&, Polynomial<CoefficientRingType> const&) const at ../../Macaulay2/e/NCAlgebras/FreeAlgebraQuotient.cpp:127
 -- 16# M2FreeAlgebraQuotient::mult(ring_elem, ring_elem) const at ../../Macaulay2/e/M2FreeAlgebraQuotient.cpp:231
 -- 17# Ring::mult_to(ring_elem&, ring_elem) const at ../../Macaulay2/e/ring.cpp:185
 -- 18# RingMap::eval_term(Ring const*, ring_elem, int const*, int, int) const at ../../Macaulay2/e/ringmap.cpp:203
 -- 19# FreeAlgebra::eval(RingMap const*, Polynomial<CoefficientRingType> const&, int) const at ../../Macaulay2/e/NCAlgebras/FreeAlgebra.cpp:757
 -- 20# RingMap::eval(RingElement const*) const at ../../Macaulay2/e/ringmap.cpp:240
jkyang92 commented 2 years ago

I can reliably reproduce this crash (on amd64) by running the following code

needsPackage "AssociativeAlgebras";
c = code (tests AssociativeAlgebras)#30;
schedule (x -> while true do (collectGarbage();nanosleep 1000));
value(c)

This has the effect of running the gc as often as possible while running the test, so that issues are are detected faster The stack trace is a bit random though. Though the common factor seems to be a segfault in accessing a gmp value.