Macaulay2 / M2

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

Duplicate large block deallocation in AssociativeAlgebras::oppositeRing example #2857

Open d-torrance opened 1 year ago

d-torrance commented 1 year ago

Here's the output from the failing build (AssociativeAlgebras::oppositeRing example):

-- -*- M2-comint -*- hash: -1318199081

i1 : R = QQ[q]/ideal{q^4+q^3+q^2+q+1}

o1 = R

o1 : QuotientRing

i2 : A = skewPolynomialRing(R,q,{x,y,z,w})
Using numthreads = 0
Using GC ring in VectorArithmetic.

o2 = A

o2 : FreeAlgebraQuotient

i3 : x*y == q*y*x

o3 = true

i4 : Aop = oppositeRing A
Using numthreads = 0
Using GC ring in VectorArithmetic.
Duplicate large block deallocation
Aborted (core dumped)

I haven't seen this particular error before, but there are few known issues that have given similar output and might be related (#35, #151, #679, #714, #2119).

Originally posted by @d-torrance in https://github.com/Macaulay2/M2/issues/2855#issuecomment-1570964773

d-torrance commented 1 year ago

This just happened in an Ubuntu 22.04 PPA build as well, so I made it an issue.

d-torrance commented 1 year ago

It happened again! Only Ubuntu 22.04 so far, which is the same release that GitHub uses. This time we got a stack trace:

_opposite__Ring.errors
**********************
o2 : FreeAlgebraQuotient

i3 : x*y == q*y*x

o3 = true

i4 : Aop = oppositeRing A
Using numthreads = 0
Using GC ring in VectorArithmetic.
-- SIGSEGV
-* stack trace, pid: 114773
 0# stack_trace(std::ostream&, bool) at ./M2/Macaulay2/d/main.cpp:123
 1# segv_handler at ./M2/Macaulay2/d/main.cpp:240
 2# 0x00007FAB7A8BC520 in /lib/x86_64-linux-gnu/libc.so.6
 3# GC_free in /lib/x86_64-linux-gnu/libgc.so.1
 4# std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<std::__detail::__variant::__deduce_visit_result<void> (*)(VectorArithmetic::safeDenseToSparse<tbb::detail::d1::null_mutex>(ElementArray&, ElementArray&, Range<int>&, int, int, MemoryBlock&, tbb::detail::d1::null_mutex&) const::{lambda(auto:1&)#1}&&, std::variant<ConcreteVectorArithmetic<M2::ARingZZpFlint, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFFlintBig, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFFlint, ElementArray>*, ConcreteVectorArithmetic<M2::ARingQQGMP, ElementArray>*, ConcreteVectorArithmetic<M2::ARingZZpFFPACK, ElementArray>*, ConcreteVectorArithmetic<M2::ARingZZp, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFM2, ElementArray>*, ConcreteVectorArithmetic<CoefficientRingR, ElementArray>*, ConcreteVectorArithmetic<CoefficientRingZZp, ElementArray>*, ConcreteVectorArithmetic<M2::DummyRing, ElementArray>*> const&)>, std::integer_sequence<unsigned long, 7ul> >::__visit_invoke(VectorArithmetic::safeDenseToSparse<tbb::detail::d1::null_mutex>(ElementArray&, ElementArray&, Range<int>&, int, int, MemoryBlock&, tbb::detail::d1::null_mutex&) const::{lambda(auto:1&)#1}&&, std::variant<ConcreteVectorArithmetic<M2::ARingZZpFlint, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFFlintBig, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFFlint, ElementArray>*, ConcreteVectorArithmetic<M2::ARingQQGMP, ElementArray>*, ConcreteVectorArithmetic<M2::ARingZZpFFPACK, ElementArray>*, ConcreteVectorArithmetic<M2::ARingZZp, ElementArray>*, ConcreteVectorArithmetic<M2::ARingGFM2, ElementArray>*, ConcreteVectorArithmetic<CoefficientRingR, ElementArray>*, ConcreteVectorArithmetic<CoefficientRingZZp, ElementArray>*, ConcreteVectorArithmetic<M2::DummyRing, ElementArray>*> const&) at /usr/include/c++/11/variant:1035
 5# void NCF4::generalReduceF4Row<tbb::detail::d1::null_mutex>(int, int, int, NCF4::NCF4Stats&, ElementArray&, bool, tbb::detail::d1::null_mutex&) at NCAlgebras/NCF4.cpp:951
 6# NCF4::reduceF4Matrix() at NCAlgebras/NCF4.cpp:1052
 7# NCF4::process(std::deque<std::tuple<int, int, int, bool>, std::allocator<std::tuple<int, int, int, bool> > > const&) at NCAlgebras/NCF4.cpp:126
 8# tbb::detail::d1::task_arena_function<NCF4::compute(int)::{lambda()#1}, void>::operator()() const at /usr/include/oneapi/tbb/task_arena.h:69
 9# 0x00007FAB7AED3521 in /lib/x86_64-linux-gnu/libtbb.so.12
10# NCF4::compute(int) at NCAlgebras/NCF4.cpp:82
11# rawNCGroebnerBasisTwoSided at interface/groebner.cpp:925
12# interface_rawNCGroebnerBasisTwoSided at ./M2/Macaulay2/d/interface.dd:4019
13# evaluate_evalraw at ./M2/Macaulay2/d/evaluate.d:1345
14# evaluate_evalSequence at ./M2/Macaulay2/d/evaluate.d:1305
15# evaluate_applyFCCS at ./M2/Macaulay2/d/evaluate.d:820
moorewf commented 1 year ago

So strange! I will see if I can track it down.

mikestillman commented 1 year ago

@moorewf Have you had any chance to try to track this down? Do you want some help from me?

d-torrance commented 1 year ago

Apparently it's not just an Ubuntu thing -- this macOS build just failed with the same bug.

mikestillman commented 1 year ago

@d-torrance Should we delay 1.22 until this is fixed?

d-torrance commented 1 year ago

I don't have a strong opinion one way or the other on whether the release should be delayed. I'm caching this example in the Debian package to get around the build errors for now.

moorewf commented 1 year ago

I have a PR for a temporary workaround for this ready. It prevents any GCed rings from using the F4 NC Groebner basis algorithm. I thought I had checks for this in place already (the code was mostly there) but apparently it was only to prevent F4 parallel code from using GC rings. Shall I submit the PR?