Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib("freegb.lib") sometimes make Conda build crash #39098

Open
2 tasks done
user202729 opened this issue Dec 9, 2024 · 5 comments
Open
2 tasks done

lib("freegb.lib") sometimes make Conda build crash #39098

user202729 opened this issue Dec 9, 2024 · 5 comments
Labels

Comments

@user202729
Copy link
Contributor

Steps To Reproduce

e.g.

https://github.com/sagemath/sage/actions/runs/12227176866/job/34103526826?pr=37447#step:9:7618

Expected Behavior

Actual Behavior

Additional Information

No response

Environment

  • OS: Conda on Ubuntu
  • Sage Version: 3.11

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@tobiasdiez
Copy link
Contributor

For reference (the build log will disappear in 2 months):

sage -t --warn-long 5.0 --random-seed=85049595565619788885733902960031249362 src/sage/rings/polynomial/plural.pyx
    SignalError in doctesting framework
**********************************************************************

Tests run before exception:
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) ## line 50 ##
sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex') ## line 51 ##
sage: P ## line 53 ##
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -x*y}
sage: y*x + 1/2 ## line 56 ##
-x*y + 1/2
sage: A.<x,y,z> = FreeAlgebra(GF(17), 3) ## line 59 ##
sage: P.<x,y,z> = A.g_algebra(relations={y*x:-x*y}, order = 'lex') ## line 60 ##
sage: P ## line 61 ##
Noncommutative Multivariate Polynomial Ring in x, y, z over Finite Field of size 17, nc-relations: {y*x: -x*y}
sage: y*x + 7 ## line 64 ##
-x*y + 7
sage: from sage.matrix.constructor import Matrix ## line 71 ##
sage: c = Matrix(3) ## line 72 ##
sage: c[0,1] = -2 ## line 73 ##
sage: c[0,2] = 1 ## line 74 ##
sage: c[1,2] = 1 ## line 75 ##
sage: d = Matrix(3) ## line 77 ##
sage: d[0, 1] = 17 ## line 78 ##
sage: P = QQ['x','y','z'] ## line 79 ##
sage: c = c.change_ring(P) ## line 80 ##
sage: d = d.change_ring(P) ## line 81 ##
sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural ## line 83 ##
sage: R.<x,y,z> = NCPolynomialRing_plural(QQ, c = c, d = d, order=TermOrder('lex',3),category=Algebras(QQ)) ## line 84 ##
sage: R ## line 85 ##
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: -2*x*y + 17}
sage: R.term_order() ## line 88 ##
Lexicographic term order
sage: a,b,c = R.gens() ## line 91 ##
sage: f = 57 * a^2*b + 43 * c + 1; f ## line 92 ##
57*x^2*y + 43*z + 1
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) ## line 97 ##
sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') ## line 98 ##
sage: TestSuite(P).run() ## line 99 ##
sage: loads(dumps(P)) is P ## line 100 ##
True
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) ## line 103 ##
sage: P = A.g_algebra(relations={y*x:-x*y}, order = 'lex') ## line 104 ##
sage: P.is_commutative() ## line 105 ##
False
sage: R.<x,y,z> = FreeAlgebra(QQ, 3) ## line 108 ##
sage: P = R.g_algebra(relations={}, order='lex') ## line 109 ##
sage: P.is_commutative() ## line 110 ##
True
sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 112 ##
0
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) ## line 156 ##
sage: H = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) ## line 157 ##

**********************************************************************
Traceback (most recent call last):
  File "parent.pyx", line 895, in sage.structure.parent.Parent.__call__
  File "coerce_dict.pyx", line 650, in sage.structure.coerce_dict.MonoDict.get
KeyError: Free Algebra on 3 generators (x, y, z) over Rational Field

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "parent.pyx", line 2501, in sage.structure.parent.Parent._internal_convert_map_from
  File "coerce_dict.pyx", line 650, in sage.structure.coerce_dict.MonoDict.get
KeyError: Free Algebra on 3 generators (x, y, z) over Rational Field

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 2596, in __call__
    doctests, extras = self._run(runner, options, results)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 2644, in _run
    result = runner.run(test)
             ^^^^^^^^^^^^^^^^
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 905, in run
    return self._run(test, compileflags, out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 716, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1137, in compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.rings.polynomial.plural.G_AlgFactory[1]>", line 1, in <module>
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/algebras/free_algebra.py", line 1018, in g_algebra
    dmat[v2_ind, v1_ind] = polynomial_ring(d_poly)
                           ^^^^^^^^^^^^^^^^^^^^^^^
  File "parent.pyx", line 897, in sage.structure.parent.Parent.__call__
  File "parent.pyx", line 2503, in sage.structure.parent.Parent._internal_convert_map_from
  File "parent.pyx", line 2524, in sage.structure.parent.Parent.discover_convert_map_from
  File "parent.pyx", line 2146, in sage.structure.parent.Parent._internal_coerce_map_from
  File "parent.pyx", line 2238, in sage.structure.parent.Parent._internal_coerce_map_from
  File "parent.pyx", line 2383, in sage.structure.parent.Parent.discover_coerce_map_from
  File "module.pyx", line 132, in sage.modules.module.Module._coerce_map_from_
  File "/usr/share/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/algebras/free_algebra.py", line 771, in _coerce_map_from_
    if isinstance(R, (FreeAlgebra_generic, FreeAlgebra_letterplace)):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lazy_import.pyx", line 966, in sage.misc.lazy_import.LazyImport.__instancecheck__
  File "lazy_import.pyx", line 224, in sage.misc.lazy_import.LazyImport.get_object
  File "lazy_import.pyx", line 259, in sage.misc.lazy_import.LazyImport._get_object
  File "free_algebra_letterplace.pyx", line 1, in init sage.algebras.letterplace.free_algebra_letterplace
  File "free_algebra_element_letterplace.pyx", line 25, in init sage.algebras.letterplace.free_algebra_element_letterplace
  File "function.pyx", line 1812, in sage.libs.singular.function.lib
cysignals.signals.SignalError: Segmentation fault

@user202729
Copy link
Contributor Author

Technically I think the bug isn't that rare so maybe there's a way to just grep through all the logs of this particular type.

… I haven't looked up whether GitHub actions have programmatic API to access it like that yet.

@tobiasdiez
Copy link
Contributor

Technically I think the bug isn't that rare so maybe there's a way to just grep through all the logs of this particular type.

… I haven't looked up whether GitHub actions have programmatic API to access it like that yet.

Have a look at #39100 if you would like to pursue this idea further.

@user202729
Copy link
Contributor Author

Curious case (normally it's outright segmentation fault, but in this case the sig_on catches it somehow)

2025-01-22T10:44:16.3718880Z **********************************************************************
2025-01-22T10:44:16.3834580Z File "src/sage/rings/polynomial/plural.pyx", line 157, in sage.rings.polynomial.plural.G_AlgFactory
2025-01-22T10:44:16.3934590Z Failed example:
2025-01-22T10:44:16.4034990Z     H = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y})
2025-01-22T10:44:16.4135730Z Exception raised:
2025-01-22T10:44:16.4236560Z     Traceback (most recent call last):
2025-01-22T10:44:16.4337020Z       File "sage/structure/parent.pyx", line 895, in sage.structure.parent.Parent.__call__
2025-01-22T10:44:16.4437520Z         mor = <map.Map> self._convert_from_hash.get(R)
2025-01-22T10:44:16.4538680Z       File "sage/structure/coerce_dict.pyx", line 650, in sage.structure.coerce_dict.MonoDict.get
2025-01-22T10:44:16.4639770Z         raise KeyError(k)
2025-01-22T10:44:16.4740970Z     KeyError: Free Algebra on 3 generators (x, y, z) over Rational Field
2025-01-22T10:44:16.4860600Z 
2025-01-22T10:44:16.4967970Z     During handling of the above exception, another exception occurred:
2025-01-22T10:44:16.5068830Z 
2025-01-22T10:44:16.5169710Z     Traceback (most recent call last):
2025-01-22T10:44:16.5270940Z       File "sage/structure/parent.pyx", line 2501, in sage.structure.parent.Parent._internal_convert_map_from
2025-01-22T10:44:16.5372970Z         return self._convert_from_hash.get(S)
2025-01-22T10:44:16.5483650Z       File "sage/structure/coerce_dict.pyx", line 650, in sage.structure.coerce_dict.MonoDict.get
2025-01-22T10:44:16.5598940Z         raise KeyError(k)
2025-01-22T10:44:16.5706340Z     KeyError: Free Algebra on 3 generators (x, y, z) over Rational Field
2025-01-22T10:44:16.5806940Z 
2025-01-22T10:44:16.5922470Z     During handling of the above exception, another exception occurred:
2025-01-22T10:44:16.6043680Z 
2025-01-22T10:44:16.6144550Z     Traceback (most recent call last):
2025-01-22T10:44:16.6245730Z       File "/Users/runner/work/sage/sage/src/sage/doctest/forker.py", line 728, in _run
2025-01-22T10:44:16.6346890Z         self.compile_and_execute(example, compiler, test.globs)
2025-01-22T10:44:16.6447940Z       File "/Users/runner/work/sage/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute
2025-01-22T10:44:16.6548970Z         exec(compiled, globs)
2025-01-22T10:44:16.6658410Z       File "<doctest sage.rings.polynomial.plural.G_AlgFactory[1]>", line 1, in <module>
2025-01-22T10:44:16.6764860Z         H = A.g_algebra({y*x:x*y-z, z*x:x*z+Integer(2)*x, z*y:y*z-Integer(2)*y})
2025-01-22T10:44:16.6866090Z             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-22T10:44:16.6967470Z       File "/Users/runner/work/sage/sage/src/sage/algebras/free_algebra.py", line 1018, in g_algebra
2025-01-22T10:44:16.7067760Z         dmat[v2_ind, v1_ind] = polynomial_ring(d_poly)
2025-01-22T10:44:16.7169250Z                                ^^^^^^^^^^^^^^^^^^^^^^^
2025-01-22T10:44:16.7271390Z       File "sage/structure/parent.pyx", line 897, in sage.structure.parent.Parent.__call__
2025-01-22T10:44:16.7370990Z         mor = <map.Map> self._internal_convert_map_from(R)
2025-01-22T10:44:16.7472930Z       File "sage/structure/parent.pyx", line 2503, in sage.structure.parent.Parent._internal_convert_map_from
2025-01-22T10:44:16.7574290Z         mor = self.discover_convert_map_from(S)
2025-01-22T10:44:16.7674790Z       File "sage/structure/parent.pyx", line 2524, in sage.structure.parent.Parent.discover_convert_map_from
2025-01-22T10:44:16.7775710Z         mor = S._internal_coerce_map_from(self)
2025-01-22T10:44:16.7876200Z       File "sage/structure/parent.pyx", line 2146, in sage.structure.parent.Parent._internal_coerce_map_from
2025-01-22T10:44:16.7977380Z         cpdef _internal_coerce_map_from(self, S):
2025-01-22T10:44:16.8078000Z       File "sage/structure/parent.pyx", line 2238, in sage.structure.parent.Parent._internal_coerce_map_from
2025-01-22T10:44:16.8193860Z         mor = self.discover_coerce_map_from(S)
2025-01-22T10:44:16.8300530Z       File "sage/structure/parent.pyx", line 2383, in sage.structure.parent.Parent.discover_coerce_map_from
2025-01-22T10:44:16.8401260Z         user_provided_mor = self._coerce_map_from_(S)
2025-01-22T10:44:16.8503160Z       File "sage/modules/module.pyx", line 132, in sage.modules.module.Module._coerce_map_from_
2025-01-22T10:44:16.8603510Z         cpdef _coerce_map_from_(self, M):
2025-01-22T10:44:16.8716200Z       File "/Users/runner/work/sage/sage/src/sage/algebras/free_algebra.py", line 771, in _coerce_map_from_
2025-01-22T10:44:16.8849400Z         if isinstance(R, (FreeAlgebra_generic, FreeAlgebra_letterplace)):
2025-01-22T10:44:16.8977760Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-22T10:44:16.9080400Z       File "sage/misc/lazy_import.pyx", line 966, in sage.misc.lazy_import.LazyImport.__instancecheck__
2025-01-22T10:44:16.9181390Z         return isinstance(x, self.get_object())
2025-01-22T10:44:16.9309310Z       File "sage/misc/lazy_import.pyx", line 224, in sage.misc.lazy_import.LazyImport.get_object
2025-01-22T10:44:16.9422700Z         return self._get_object()
2025-01-22T10:44:16.9525060Z       File "sage/misc/lazy_import.pyx", line 259, in sage.misc.lazy_import.LazyImport._get_object
2025-01-22T10:44:16.9638130Z         self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
2025-01-22T10:44:16.9738990Z       File "sage/algebras/letterplace/free_algebra_letterplace.pyx", line 1, in init sage.algebras.letterplace.free_algebra_letterplace
2025-01-22T10:44:16.9839630Z         ###############################################################################
2025-01-22T10:44:16.9940940Z       File "sage/algebras/letterplace/free_algebra_element_letterplace.pyx", line 25, in init sage.algebras.letterplace.free_algebra_element_letterplace
2025-01-22T10:44:17.0041960Z         lib("freegb.lib")
2025-01-22T10:44:17.0142850Z       File "sage/libs/singular/function.pyx", line 1805, in sage.libs.singular.function.lib
2025-01-22T10:44:17.0249160Z         sig_on()
2025-01-22T10:44:17.0350490Z     RuntimeError: Aborted
2025-01-22T10:44:17.0451490Z **********************************************************************

From #39142 but it's probably unrelated.

@user202729
Copy link
Contributor Author

user202729 commented Jan 24, 2025

I found an undefined behavior there…

maybe on Mac the calling convention is different between these 2 types to cause a segmentation fault. (on x86 it looks harmless.)

EDIT: actually it's unrelated… the generated C code doesn't include the function declaration at all.

There's a memory leak there though, because the function doesn't consume the string so the omStrDup is actually redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants