I have create https://trac.sagemath.org/ticket/30427 for the memory leak in divisors of integers.
jonatha...@googlemail.com schrieb am Freitag, 21. August 2020 um 09:08:44 UTC+2: > I can confirm the rings/integer.pyx failure from running it in the shell. > > sage: n = prod(primes_first_n(25)) > sage: _ = n.divisors() > > If I cancel the second line many time (after a few seconds each), I see an > increase in memory usage. > There doesn't seem to be a limit to it. > > I can immitate the problem by the following (this is what divisors does > along the way): > > sage: cython(''' > ....: from sage.rings.integer cimport Integer > ....: from sage.ext.stdsage cimport PY_NEW > ....: from cysignals.signals cimport sig_check > ....: def foo(): > ....: cdef list sorted = [] > ....: cdef Integer apn > ....: cdef Py_ssize_t i > ....: for i in range(100000000): > ....: apn = <Integer>PY_NEW(Integer) > ....: sorted.append(apn) > ....: sig_check() > ....: ''') > > If I cancel the function foo after a few seconds, it leaks. > > Looks to me like this list isn't garbage collected at interrupt. > > Btw, note that alarm might be triggered much later than expected: > > sage: def test_alarm(): > ....: n = prod(primes_first_n(25)) > ....: try: > ....: alarm(RDF.random_element(1e-3,0.5)) > ....: _ = n.divisors() > ....: sleep(20) > ....: except AlarmInterrupt: > ....: pass > ....: > > > > sage: %time > test_alarm() > > > > CPU times: user 127 ms, sys: 24 ms, total: 151 ms > Wall time: 150 ms > sage: %time > test_alarm() > > > > CPU times: user 1.22 s, sys: 88.1 ms, total: 1.31 s > Wall time: 1.31 s > Steven Trogdon schrieb am Freitag, 21. August 2020 um 00:22:32 UTC+2: > >> I've seen the following failures when doctesting Sage-on-Gentoo but I'm >> now seeing them when doctesting vanilla Sage: >> >> sage -t --long --warn-long 165.2 --random-seed=0 >> src/sage/rings/integer.pyx >> ********************************************************************** >> File "src/sage/rings/integer.pyx", line 3100, in >> sage.rings.integer.Integer.divisors >> Failed example: >> for i in range(20): # long time >> try: >> alarm(RDF.random_element(1e-3, 0.5)) >> _ = n.divisors() >> cancel_alarm() # we never get here >> except AlarmInterrupt: >> pass >> Exception raised: >> Traceback (most recent call last): >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 715, in _run >> self.compile_and_execute(example, compiler, test.globs) >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 1139, in compile_and_execute >> exec(compiled, globs) >> File "<doctest sage.rings.integer.Integer.divisors[20]>", line 4, >> in <module> >> _ = n.divisors() >> File "sage/rings/integer.pyx", line 3170, in >> sage.rings.integer.Integer.divisors >> (build/cythonized/sage/rings/integer.c:20840) >> ptr = <unsigned long*>check_allocarray(divisor_count, 3 * >> sizeof(unsigned long)) >> File "memory.pxd", line 87, in cysignals.memory.check_allocarray >> (build/cythonized/sage/rings/integer.c:47465) >> MemoryError: failed to allocate 33554432 * 24 bytes >> ********************************************************************** >> File "src/sage/rings/integer.pyx", line 3912, in >> sage.rings.integer.Integer.? >> Failed example: >> n.factor(proof=True) >> Exception raised: >> Traceback (most recent call last): >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 715, in _run >> self.compile_and_execute(example, compiler, test.globs) >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 1139, in compile_and_execute >> exec(compiled, globs) >> File "<doctest sage.rings.integer.Integer.?[9]>", line 1, in >> <module> >> n.factor(proof=True) >> File "sage/rings/integer.pyx", line 3994, in >> sage.rings.integer.Integer.factor >> (build/cythonized/sage/rings/integer.c:25893) >> F = factor_using_pari(n, int_=int_, debug_level=verbose, >> proof=proof) >> File "sage/rings/factorint.pyx", line 345, in >> sage.rings.factorint.factor_using_pari >> (build/cythonized/sage/rings/factorint.c:6481) >> p, e = n.__pari__().factor(proof=proof) >> File "cypari2/gen.pyx", line 4311, in cypari2.gen.Gen.factor >> cysignals.signals.AlarmInterrupt >> ********************************************************************** >> >> and >> >> sage -t --long --warn-long 165.2 --random-seed=0 src/sage/doctest/test.py >> ********************************************************************** >> File "src/sage/doctest/test.py", line 521, in sage.doctest.test >> Failed example: >> if system() == "Linux": >> P = subprocess.Popen(["sage", "-t", "--warn-long", "0", >> "--random-seed=0", "--memlimit=2000", "memlimit.rst"], >> stdout=subprocess.PIPE, **kwds) >> out, err = P.communicate() >> ok = ("MemoryError: failed to allocate" in bytes_to_str(out)) >> Expected nothing >> Got: >> Process DocTestWorker-1: >> Traceback (most recent call last): >> File >> "/local/sage-git/sage/local/lib/python3.7/multiprocessing/process.py", line >> 297, in _bootstrap >> self.run() >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 2185, in run >> task(self.options, self.outtmpfile, msgpipe, self.result_queue) >> File >> "/local/sage-git/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", >> >> line 2535, in __call__ >> result_queue.put(result, False) >> File >> "/local/sage-git/sage/local/lib/python3.7/multiprocessing/queues.py", line >> 87, in put >> self._start_thread() >> File >> "/local/sage-git/sage/local/lib/python3.7/multiprocessing/queues.py", line >> 170, in _start_thread >> self._thread.start() >> File "/local/sage-git/sage/local/lib/python3.7/threading.py", line >> 847, in start >> _start_new_thread(self._bootstrap, ()) >> RuntimeError: can't start new thread >> >> >> On Tuesday, August 18, 2020 at 5:01:42 PM UTC-6, Volker Braun wrote: >> >>> As always, you can get the latest beta version from the "develop" git >>> branch. Alternatively, the self-contained source tarball is at >>> http://www.sagemath.org/download-latest.html >>> >>> >>> 548666e9f2 (tag: 9.2.beta9, trac/develop) Updated SageMath version to >>> 9.2.beta9 >>> 842a6866f1 Trac #29974: Make combinat doctests ready for random seeds >>> 1de1d457b4 Trac #29971: Make categories doctests ready for random seeds >>> 6864757e11 Trac #29968: Make algebras doctests ready for random seeds >>> b526019731 Trac #29963: Make geometry doctests ready for random seeds >>> 719f9af12c Trac #29509: rational_points fails for some hyperelliptic >>> curves >>> 4d5ab773b5 Trac #29257: use solve_left for division operation of matrices >>> e18e84219d Trac #30365: Disable LTO in matplotlib build >>> 01f536726d Trac #29989: fix random test failures in PSage interface >>> f531b354f7 Trac #30345: build/make/Makefile.in: Filter out "-j" from >>> sub-make invocations to avoid excessive parallel load >>> 8417e64af6 Trac #29511: Broken coercion between cyclotomic fields >>> b4a8c5745b Trac #29325: Set up permutahedron with both Vrep and Hrep (if >>> backend supports it) >>> 9b14ca3e86 Trac #29248: Index notation for tensors should allow for >>> unicode characters >>> a331d47ef3 Trac #28966: Provide unicode aliases for some globals in >>> Python 3 >>> 95d0cd5b9e Trac #28951: Fixing a bug in >>> sage.schemes.cyclic_covers.charpoly_frobenius >>> 4986d5ea7f Trac #28816: database_stein_watkins Python 3 issues >>> 193e14365a Trac #30127: cygwin-minimal: pip-20.1.1 fails to install >>> a92871805f Trac #26919: Upgrade Jupyter notebook to latest (6.1.1) and >>> its dependencies to latest >>> 66472811de Trac #30251: ExtPowerFreeModule, ExtPowerDualFreeModule: >>> Simplify _repr_ >>> 7030fa15a7 Trac #30175: Remove outdated spkg-src script for ecl >>> 11bb005e98 Trac #30165: normalize_coordinates broken for p-adic fields >>> 82568e3cbd Trac #30044: tox.ini: Test on voidlinux >>> 294931e00b Trac #30339: tox.ini: Update for latest ubuntu, fedora >>> versions >>> ea615c4ce6 Trac #30331: Issue with toric_substitute for Laurent >>> polynomials >>> df3cf63875 Trac #30327: affine group element * a polytope raises KeyError >>> 9cfaefb544 Trac #30303: Graphs: two families of distance-regular graphs >>> 81a7e50cd2 Trac #30301: Italian translation of FAQ >>> 48fb9141da Trac #30286: Graph: last sporadic distance-regular graphs >>> 6f2561fdca Trac #30260: Graphs: more distance-regular graphs >>> 29098c6af9 Trac #30240: Graphs: a few distance-regular graphs >>> 1b8dff7172 Trac #30178: Manifolds: add orientability >>> 24eb3aa28d Trac #29911: sage.rings.integer, integer_ring: Remove >>> dependencies on sage.libs.ntl >>> 8b9743d0af Trac #29654: Improve face generator of polyhedra by exposing >>> `FaceIterator` class >>> c0b61fd5cf Trac #28904: Move reversed graph from backend to CGraph for >>> sparse graphs >>> 04c64492a6 Trac #30335: openblas: clear out .pc symlinks before >>> installation >>> ef6132b817 Trac #25363: Add '--simple-prompt' argument for sage >>> 3682402983 Trac #30277: Remove src/module_list.py >>> 0cc658a1f9 Trac #30257: Fusion Ring - Rmatrix >>> 6ffe4c9e55 Trac #30209: Action for Bundle Connections >>> eaa2f0a361 Trac #29950: Build sagelib from build/pkgs/sagelib/src, fix >>> `setup.py sdist`, add spkg-src and tox.ini >>> e002ee071c Trac #29539: Bug in saturation of elliptic curves over number >>> fields >>> a4b8705ae5 Trac #30330: `cdd` backend fails to initialize empty >>> polyhedron from double description >>> c3e5ce6ea1 Trac #30292: is_pyramid returns a wrong certificate >>> 3d594b5cc6 Trac #30262: Update e-antic to 0.1.8 >>> 415221a9a8 (tag: 9.2.beta8) Updated SageMath version to 9.2.beta8 >>> >>> -- You received this message because you are subscribed to the Google Groups "sage-release" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-release+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-release/955babb9-ee0f-4a8e-8470-3dfe08dd4e39n%40googlegroups.com.