Macaulay2 / M2

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

debug build & flint #354

Closed bapike closed 8 years ago

bapike commented 8 years ago

I pulled a7cdee1fafb57cd3a62fcf94293a066d1971281a and tried to do a build on Debian 8 with these parameters:

./configure --enable-download --prefix=/home/bapike/git/M2-test --disable-ntl-wizard --enable-build-libraries="ntl pari" --enable-debug

It fails to build because DEBUG is defined via the compiler calls and flint-2.4.5/fmpz_factor/factor_pp1.c has:

#define DEBUG 0 /* turn on some trace information */

Changing this to

/* DEBUG can be defined on the command line... */
#ifdef DEBUG
#undef DEBUG
#endif

#define DEBUG 0 /* turn on some trace information */

allows the build to finish. However, about 18 tests fail with the message:

M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.

Picking one of these, the message is reproducible by just running

GF 9

in a debug build of Macaulay2. GDB says:

M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff2e66700 (LWP 17086)]
0x00007ffff40ea107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff40ea107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff40eb4e8 in __GI_abort () at abort.c:89
#2  0x00007ffff40e3226 in __assert_fail_base (fmt=0x7ffff4219ce8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0xb9f658 "*cp == -1", file=file@entry=0xb9f646 "ctx_init_conway.c", line=line@entry=45, 
    function=function@entry=0xb9f750 <__PRETTY_FUNCTION__.8643> "_fq_nmod_ctx_init_conway") at assert.c:92
#3  0x00007ffff40e32d2 in __GI___assert_fail (assertion=assertion@entry=0xb9f658 "*cp == -1", file=file@entry=0xb9f646 "ctx_init_conway.c", line=line@entry=45, 
    function=function@entry=0xb9f750 <__PRETTY_FUNCTION__.8643> "_fq_nmod_ctx_init_conway") at assert.c:101
#4  0x0000000000a68e75 in _fq_nmod_ctx_init_conway (ctx=0x7ffff2e64a60, p=0x7ffff2e64a50, d=2, var=0xb115b1 "a") at ctx_init_conway.c:45
#5  0x000000000067af37 in findConwayPolynomial (charac=3, deg=2, find_random_if_no_conway_poly_available=<optimized out>, result_poly=std::vector of length 0, capacity 0) at x-relem.cpp:1367
#6  0x000000000067b08f in rawConwayPolynomial (charac=<optimized out>, deg=<optimized out>, find_random_if_no_conway_poly_available=<optimized out>) at x-relem.cpp:1398
#7  0x00000000004dc415 in interface_rawConwayPolynomial (e=<optimized out>) at interface.dd:655
#8  0x00000000004981fc in evaluate_eval (c=0x3e7c980) at evaluate.d:1270
#9  0x000000000049b963 in evaluate_applyFCCS (c=c@entry=0x316d060, cs=<optimized out>) at evaluate.d:828
#10 0x000000000049f775 in evaluate_applyFCC (fc=fc@entry=0x316d060, ec=<optimized out>) at evaluate.d:558
#11 0x000000000049719b in evaluate_eval (c=0x3ec6160) at evaluate.d:1266
#12 0x00000000004968b9 in evaluate_eval (c=0x3ec6250) at evaluate.d:1302
#13 0x000000000049676a in evaluate_eval (c=0x31b7320) at evaluate.d:1369
#14 0x0000000000499d43 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:518
#15 0x000000000049719b in evaluate_eval (c=c@entry=0x1afbd90) at evaluate.d:1266
#16 0x00000000004b9d9a in scan_1 (a=0x31bb5e0, f=<optimized out>) at actors3.d:1732
#17 0x00000000004981fc in evaluate_eval (c=0x1afbe30) at evaluate.d:1270
#18 0x0000000000498238 in evaluate_eval (c=0x1afbed0) at evaluate.d:1330
#19 0x0000000000499d43 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:518
#20 0x00000000004983f7 in evaluate_eval (c=0x3d54d90) at evaluate.d:1279
#21 0x00000000004968b9 in evaluate_eval (c=0x3d54de0) at evaluate.d:1302
#22 0x000000000049676a in evaluate_eval (c=0x3d52aa0) at evaluate.d:1369
#23 0x0000000000498238 in evaluate_eval (c=0x3d50570) at evaluate.d:1330
#24 0x000000000049872c in evaluate_eval (c=0x3d52ce0) at evaluate.d:1384
#25 0x0000000000499d43 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:518
#26 0x00000000004981ed in evaluate_eval (c=0x1940340) at evaluate.d:1274
#27 0x000000000049a169 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:461
#28 0x00000000004b043d in iteratedApply (e=<optimized out>) at actors3.d:2097
#29 0x00000000004981fc in evaluate_eval (c=0x18de750) at evaluate.d:1270
#30 0x000000000049a169 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:461
#31 0x0000000000497313 in evaluate_eval (c=0x3d5f890) at evaluate.d:1277
#32 0x00000000004968b9 in evaluate_eval (c=0x3d5f8e0) at evaluate.d:1302
#33 0x0000000000498694 in evaluate_eval (c=0x3d5c7e0) at evaluate.d:1380
#34 0x0000000000499d43 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:518
#35 0x00000000004981ed in evaluate_eval (c=0x1940340) at evaluate.d:1274
#36 0x000000000049a169 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:461
#37 0x00000000004b043d in iteratedApply (e=<optimized out>) at actors3.d:2097
#38 0x00000000004981fc in evaluate_eval (c=0x18de750) at evaluate.d:1270
#39 0x000000000049a169 in evaluate_applyFCS (c=<optimized out>, v=<optimized out>) at evaluate.d:461
#40 0x0000000000497313 in evaluate_eval (c=0x3d63700) at evaluate.d:1277
#41 0x0000000000498057 in evaluate_eval (c=0x3d65c20) at evaluate.d:1374
#42 0x000000000049ae85 in evaluate_applyFCE (fc=<optimized out>, e=<optimized out>) at evaluate.d:738
#43 0x00000000004981ed in evaluate_eval (c=0x1940340) at evaluate.d:1274
#44 0x000000000049ae85 in evaluate_applyFCE (fc=<optimized out>, e=<optimized out>) at evaluate.d:738
#45 0x00000000004b043d in iteratedApply (e=<optimized out>) at actors3.d:2097
#46 0x00000000004a07f1 in evaluate_applyFCC (fc=fc@entry=0x3d24f60, ec=<optimized out>) at evaluate.d:658
#47 0x0000000000497313 in evaluate_eval (c=c@entry=0x3bee700) at evaluate.d:1277
#48 0x00000000004a2d7c in evaluate_evalexcept (c=c@entry=0x3bee700) at evaluate.d:1404
#49 0x0000000000503205 in readeval4 (returnIfError=<optimized out>, stopIfBreakReturnContinue=<optimized out>, returnLastvalue=0 '\000', dictionary=0x3beef70, printout=<optimized out>, file=0x17f2da0) at interp.d:177
#50 readeval3 (file=file@entry=0x17f2da0, printout=printout@entry=1 '\001', dc=dc@entry=0x17f2de0, returnLastvalue=returnLastvalue@entry=0 '\000', stopIfBreakReturnContinue=stopIfBreakReturnContinue@entry=0 '\000', 
    returnIfError=returnIfError@entry=0 '\000') at interp.d:271
#51 0x0000000000503f80 in loadprint (filename=0x1593d70, dc=0x17f2de0, returnIfError=returnIfError@entry=0 '\000') at interp.d:342
#52 0x000000000050431b in commandInterpreter_2 (e=0x1490e30) at interp.d:459
#53 0x00000000004981fc in evaluate_eval (c=0x3be9520) at evaluate.d:1270
#54 0x00000000004968b9 in evaluate_eval (c=0x3be9610) at evaluate.d:1302
#55 0x0000000000498694 in evaluate_eval (c=c@entry=0x17ee020) at evaluate.d:1380
#56 0x00000000004a2d7c in evaluate_evalexcept (c=c@entry=0x17ee020) at evaluate.d:1404
#57 0x0000000000503205 in readeval4 (returnIfError=<optimized out>, stopIfBreakReturnContinue=<optimized out>, returnLastvalue=0 '\000', dictionary=0x1605ed0, printout=<optimized out>, file=0x16074e0) at interp.d:177
#58 readeval3 (file=file@entry=0x16074e0, printout=printout@entry=0 '\000', dc=<optimized out>, returnLastvalue=returnLastvalue@entry=0 '\000', stopIfBreakReturnContinue=stopIfBreakReturnContinue@entry=0 '\000', 
    returnIfError=returnIfError@entry=0 '\000') at interp.d:271
#59 0x0000000000504430 in readeval (file=0x16074e0, returnLastvalue=returnLastvalue@entry=0 '\000', returnIfError=returnIfError@entry=0 '\000') at interp.d:281
#60 0x000000000050556d in interp_process () at interp.d:594
#61 0x0000000000465808 in interpFunc (vargs2=<optimized out>) at M2lib.c:604
#62 0x00000000006dfa1b in ThreadTask::run (this=0x15feda0, thread=thread@entry=0x148b430) at supervisor.cpp:360
#63 0x00000000006dfbe8 in SupervisorThread::threadEntryPoint (this=0x148b430) at supervisor.cpp:422
#64 0x00000000006e0149 in SupervisorThread::threadEntryPoint (st=<optimized out>) at supervisor.hpp:96
#65 0x00007ffff5576d6e in GC_inner_start_routine () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#66 0x00007ffff5572102 in GC_call_with_stack_base () from /usr/lib/x86_64-linux-gnu/libgc.so.1
#67 0x00007ffff4bc50a4 in start_thread (arg=0x7ffff2e66700) at pthread_create.c:309
#68 0x00007ffff419b04d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

I think the failed assert is from the M2 patch to flint.

DanGrayson commented 8 years ago

Mike, you often build the debug version, although on the Mac mostly. Is there some reason you haven't seen the same problem?

bapike commented 8 years ago

Sorry, when I said "tests" I meant "examples from Macaulay2Doc". Here's the output of ls *error* |xargs tail -n 4 run in the .../Macaulay2Doc/example-output directory:

==> _ambient_lp__Galois__Field_rp.errors <==

i1 : F = GF(25,Variable=>a)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _benchmark.errors <==

i1 : benchmark "sqrt 2p100000"
mulmod_2expp1_basecase.c:51: GNU MP assertion failed: !((xp) + (n) > (yp) && (yp) + (n) > (xp))
Aborted

==> _coefficient.errors <==

i1 : R = GF(25,Variable=>a)[x,y,z];
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _degree__Length.errors <==

i4 : degreeLength (GF 9)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _finite_spfields.errors <==

i1 : F = GF(81,Variable=>a)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _generators_lp__Module_rp.errors <==

i1 : R = GF(8,Variable=>a)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> ___G__F.errors <==

i1 : A = GF(3,2,Variable=>b);
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _is__Field.errors <==

i3 : isField GF(2,3)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _is__Polynomial__Ring.errors <==

i4 : isPolynomialRing(GF(2)[x,y, SkewCommutative => true])
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _is__Ring.errors <==

i5 : isRing(GF(2,3)[x,dx, WeylAlgebra => {x => dx}])
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _map_lp__Module_cm__Z__Z_cm__Function_rp.errors <==

i1 : R = GF(9,Variable=>a)[x,y,z];
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _numgens_lp__Ring_rp.errors <==

i12 : K = GF(9,Variable=>a)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _random_lp__Type_rp.errors <==

i3 : tally for i to 100 list random GF 11
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _random_spand_spgeneric_spmatrices.errors <==

i1 : R = GF(3^2,Variable => a);
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> ___Ring__Element_sp_sl_sp__Ring__Element.errors <==

i2 : R = GF(9,Variable=>a);
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> ___Ring_sp_sl_sp__Ideal.errors <==

i7 : D = GF(9,Variable=>a)[x,y]/(y^2 - x*(x-1)*(x-a))
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> ___Singular_sp__Book_sp1.1.8.errors <==

i10 : A2 = GF(8,Variable=>a)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> ___Singular_sp__Book_sp1.1.9.errors <==

i5 : C = GF(8)[x,y,z];
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

==> _solve.errors <==

i6 : kk = GF(25)
M2-binary: ctx_init_conway.c:45: _fq_nmod_ctx_init_conway: Assertion `*cp == -1' failed.
Aborted

The second error (_benchmark.errors) is known in #35.

bapike commented 8 years ago

Using git-bisect suggests that for the _fq_nmod_ctx_init_conway issue, the first bad commit was 28a128a76798f1d7b7f1e037046c2c46f23ef32e, but that's where the assertion in question was added.

DanGrayson commented 8 years ago

Thanks, I'm assigning that to myself.

Any FLINT release containing commit a407a40e01aaf1a5b050c813ae65c10eb1148cc1 contains my patch, so you could probably succeed by using the latest FLINT release, if it includes that. If I introduced a bug in DEBUG mode, they must have fixed it by now, since that was in July.

Another idea is to just remove the offending assertion.

Let me know if it works.

bapike commented 8 years ago

For GF(p^d), the Conway polynomial has degree d, so d+1 coefficients. The CPimport array has all d+1 coefficients, but M2's patch to flint-2.4.5 and the flint commit you mentioned only pull d coefficients and hard-code the fact that the polynomial should be monic. At the line containing the assert, the pointer is pointing to the monic coefficient (i.e., 1); the following entry is -1 and indicates the separator between Conway polynomials. The flint code doesn't have any asserts, so there haven't been any failures.

So, the only bug is that the assertion fails. I can send you a pull request that comments out the asserts.

But, I don't think anyone's been using the debug builds.

mikestillman commented 8 years ago

Generally, I use the debug builds in M2 quite a bit. But I hadn’t noticed this problem.

— mike

On Nov 19, 2015, at 11:54 AM, Brian Pike notifications@github.com wrote:

For GF(p^d), the Conway polynomial has degree d, so d+1 coefficients. The CPimport array has all d+1 coefficients, but M2's patch to flint-2.4.5 and the flint commit you mentioned only pull d coefficients and hard-code the fact that the polynomial should be monic. At the line containing the assert, the pointer is pointing to the monic coefficient (i.e., 1); the following entry is -1 and indicates the separator between Conway polynomials. The flint code doesn't have any asserts, so there haven't been any failures.

So, the only bug is that the assertion fails. I can send you a pull request that comments out the asserts.

But, I don't think anyone's been using the debug builds.

— Reply to this email directly or view it on GitHub https://github.com/Macaulay2/M2/issues/354#issuecomment-158116968.