M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Segfault in GBRing::gbvector_remove

Open d-torrance opened this issue 2 years ago • 5 comments

I got the following segfault in an Ubuntu 18.04 PPA build for amd64. Is this some of the code that was just updated in #2769?

 -- capturing check(12, "SubalgebraBases")                                  -- SIGSEGV
-* stack trace, pid: 156733
 0# stack_trace(std::ostream&, bool) at ./M2/Macaulay2/d/main.cpp:127
 1# segv_handler at ./M2/Macaulay2/d/main.cpp:244
 2# 0x00007F144EC83F10 in /lib/x86_64-linux-gnu/libc.so.6
 3# GBRing::gbvector_remove(gbvector*) at ./M2/Macaulay2/e/gbring.cpp:289
 4# ReducedGB::~ReducedGB() at ./M2/Macaulay2/e/reducedgb.cpp:47
 5# 0x00007F14504FE74D in /usr/lib/x86_64-linux-gnu/libgc.so.1
 6# 0x00007F14504FE9D4 in /usr/lib/x86_64-linux-gnu/libgc.so.1

d-torrance avatar Feb 10 '23 16:02 d-torrance

@d-torrance @mahrud Hmmm, I would not think so, but I'll take a look. It seems like a likely culprit

mikestillman avatar Feb 11 '23 08:02 mikestillman

I don't seem to be able to reproduce it. #2769 only changed some names without any actual mathematical changes, so I would be surprised if that is the cause, but it could be related to #2740, or possibly a pre-existing bug is revealed due to the new changes. Has this been happening consistently or was it a one-off thing?

Also, I think a few lines later in the stack trace may be more relevant:

 7# 0x00007F1450500E4D in /usr/lib/x86_64-linux-gnu/libgc.so.1
 8# 0x00007F145050977A in /usr/lib/x86_64-linux-gnu/libgc.so.1
 9# getmem_atomic at ./M2/Macaulay2/d/M2mem.c:119
10# Matrix::monomials(M2_arrayint_struct*) const at ./M2/Macaulay2/e/matrix.cpp:1714
11# interface_rawMonomials at ./M2/Macaulay2/d/interface.dd:2631

In particular, this is something that may have changed: https://github.com/Macaulay2/M2/blob/8dce7410efd73d98af4a4f6c93675d27b57103c7/M2/Macaulay2/e/matrix.cpp#L1713-L1718 Here is where exp is defined. https://github.com/Macaulay2/M2/blob/8dce7410efd73d98af4a4f6c93675d27b57103c7/M2/Macaulay2/e/matrix.cpp#L1701

mahrud avatar Feb 12 '23 05:02 mahrud

Has this been happening consistently or was it a one-off thing?

I've only seen it the one time so far.

d-torrance avatar Feb 12 '23 12:02 d-torrance

Seems like too big of a coincidence for this not to be related: https://github.com/Macaulay2/M2/pull/2776#issuecomment-1428248210

mahrud avatar Feb 15 '23 17:02 mahrud

This popped up for the first time in a while in this build: https://github.com/Macaulay2/M2/actions/runs/10872827054/job/30168286702

Here's the output:

i5 : R = QQ[x_1..x_9, MonomialOrder => Lex];

i6 : eqns := {x_1^2+x_2^2+x_3^2-1, x_1*x_4+x_2*x_5+x_3*x_6,
         x_1*x_7+x_2*x_8+x_3*x_9, x_1*x_4+x_2*x_5+x_3*x_6,
         x_4^2+x_5^2+x_6^2-1, x_4*x_7+x_5*x_8+x_6*x_9,
         x_1*x_7+x_2*x_8+x_3*x_9, x_4*x_7+x_5*x_8+x_6*x_9,
         x_7^2+x_8^2+x_9^2-1,
         x_1*x_5*x_9-x_1*x_6*x_8-x_2*x_4*x_9+x_2*x_6*x_7+x_3*x_4*x_8-x_3*x_5*x_7-1};

i7 : sag1 = subring sagbi eqns;
-- SIGSEGV
-* stack trace, pid: 127292
 0# stack_trace(std::ostream&, bool) at ../../../../Macaulay2/d/main.cpp:132
 1# segv_handler at ../../../../Macaulay2/d/main.cpp:249
 2# 0x00007FE1C9445320 in /lib/x86_64-linux-gnu/libc.so.6
 3# GBRing::gbvector_remove(gbvector*) at ../../../../Macaulay2/e/gbring.cpp:289
 4# gbA::remove_gb() at ../../../../Macaulay2/e/gb-default.cpp:264
 5# remove_gb at ../../../../Macaulay2/e/finalize.cpp:108
 6# GC_invoke_finalizers in /lib/x86_64-linux-gnu/libgc.so.1
 7# 0x00007FE1CA46DDD9 in /lib/x86_64-linux-gnu/libgc.so.1
 8# GC_generic_malloc_many in /lib/x86_64-linux-gnu/libgc.so.1
 9# GC_malloc_kind in /lib/x86_64-linux-gnu/libgc.so.1
10# newClass(tagged_union*, parse_HashTable_struct*, char) at ../../../../Macaulay2/d/actors2.dd:238
11# evaluate_evalraw at ../../../../Macaulay2/d/evaluate.d:1518
12# evaluate_applyEEE at ../../../../Macaulay2/d/evaluate.d:992
13# newfromfun(tagged_union*, tagged_union*) at ../../../../Macaulay2/d/actors2.dd:342
14# evaluate_evalraw at ../../../../Macaulay2/d/evaluate.d:1518
15# evaluate_applyFCS at ../../../../Macaulay2/d/evaluate.d:568

d-torrance avatar Sep 17 '24 20:09 d-torrance