#28162 closed defect (duplicate)

AlarmInterrupt in divisors doctest in integer.pyx

Reported by: gh-mwageringel Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: memleak Keywords:
Cc: jdemeyer Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


The following doctest for divisors() in integer.pyx raises an AlarmInterrupt on some machines (using CentOS 7.6.1810).

$ ./sage -t --long src/sage/rings/integer.pyx
Running doctests with ID 2019-07-10-22-17-10-03f99627.
Git branch: develop
Using --optional=build,dochtml,memlimit,mpir,python2,sage
Doctesting 1 file.
sage -t --long --warn-long 85.5 src/sage/rings/integer.pyx
File "src/sage/rings/integer.pyx", line 3009, in sage.rings.integer.Integer.divisors
Failed example:
    for i in range(20):  # long time
            alarm(RDF.random_element(1e-3, 0.5))
            _ = n.divisors()
            cancel_alarm()  # we never get here
        except AlarmInterrupt:
Exception raised:
    Traceback (most recent call last):
      File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 1105, 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 3079, in sage.rings.integer.Integer.divisors (build/cythonized/sage/rings/integer.c:19781)
        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:47091)
    MemoryError: failed to allocate 33554432 * 24 bytes
    AlarmInterrupt in doctesting framework
Tests run before doctest exception:
sage: a = Integer(3) ; b = Integer(4) ## line 11 ##


sage: n = -920384; n.__hash__() ## line 3586 ##
Traceback (most recent call last):
  File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 2487, in __call__
    doctests, extras = self._run(runner, options, results)
  File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 2536, in _run
    result = runner.run(test)
  File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 879, in run
    return self._run(test, compileflags, out)
  File "/amd/compute/mwagerin/git/sage_compute/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 622, in _run
    print("sage: " + example.source[:-1] + " ## line %s ##"%(test.lineno + example.lineno + 1))
  File "src/cysignals/signals.pyx", line 320, in cysignals.signals.python_check_interrupt

sage -t --long --warn-long 85.5 src/sage/rings/integer.pyx  # AlarmInterrupt in doctesting framework

The second half of the output varies, as sometimes the AlarmInterrupt is observed during one of the subsequent doctests of the file.

Change History (4)

comment:1 Changed 20 months ago by gh-mwageringel

  • Cc jdemeyer added

Ticket #26002 might be related, as the same error is mentioned there. The affected doctest was added in #8573 and is meant to check for memory leaks. Is this actually a memory leak?

comment:2 Changed 20 months ago by jdemeyer

The real cause seems to be MemoryError: failed to allocate 33554432 * 24 bytes

Is this a machine with few RAM?

comment:3 Changed 20 months ago by gh-mwageringel

  • Milestone changed from sage-8.9 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Oh, good point. The machine has plenty of RAM, but I had not realized that this is another incarnation of #28106 where the memlimit is hit during doctests. Raising it just a bit from 3300 to 3400 makes the test pass.

This ticket can be closed as duplicate – my bad. Thank you for the help.

comment:4 Changed 20 months ago by chapoton

  • Resolution set to duplicate
  • Status changed from needs_review to closed
Note: See TracTickets for help on using tickets.