-
-
Notifications
You must be signed in to change notification settings - Fork 4
Fix tests (esp. memory) #308
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
Draft
skirpichev
wants to merge
4
commits into
diofant:master
Choose a base branch
from
skirpichev:memory-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+22
−23
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This permits to prevent loading of the hypothesis plugin, if it's disabled by -p no:hypothesispytest.
Member
Author
|
test_fac_outofmem() on pypy crashes even for builtin int's, for following diff: diff --git a/tests/test_memory.py b/tests/test_memory.py
index d19a14b..4402cf5 100644
--- a/tests/test_memory.py
+++ b/tests/test_memory.py
@@ -3,9 +3,11 @@ import platform
import random
import threading
from concurrent.futures import ThreadPoolExecutor
+from math import factorial as fac
import pytest
-from gmp import fac, mpz
+
+mpz = int
if platform.system() != "Linux":
pytest.skip("FIXME: setrlimit fails with ValueError on MacOS", |
Member
Author
|
Pure-python code in PyPy: # a.py
import gc
import platform
import random
import resource
from math import factorial as fac
VMEM_LIMIT = 64*1000**2
if platform.python_implementation() == "PyPy":
VMEM_LIMIT = 128*1000**2
mpz = int
def test_fac_outofmem():
for _ in range(20):
x = random.randint(12811, 24984)
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (VMEM_LIMIT, hard))
a = mpz(x)
while True:
try:
fac(a)
a *= 2
except MemoryError:
del a
gc.collect()
break
resource.setrlimit(resource.RLIMIT_AS, (soft, hard))
test_fac_outofmem()$ python --version
Python 3.11.13 (413c9b7f57f5, Jul 03 2025, 18:03:56)
[PyPy 7.3.20 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
$ python a.py
RPython traceback:
File "pypy_module_pypyjit.c", line 955, in portal_13
File "pypy_interpreter_2.c", line 58300, in handle_bytecode__AccessDirect_None
File "pypy_interpreter_3.c", line 40858, in dispatch_bytecode__AccessDirect_None
out of memory: couldn't allocate a few KB more
AbortedAnother: # b.py
import gc
import platform
import random
import resource
from math import factorial as fac
VMEM_LIMIT = 64*1000**2
if platform.python_implementation() == "PyPy":
VMEM_LIMIT = 128*1000**2
mpz = int
def test_square_outofmem():
for _ in range(20):
x = random.randint(49846727467293, 249846727467293)
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
resource.setrlimit(resource.RLIMIT_AS, (VMEM_LIMIT, hard))
mx = mpz(x)
i = 1
while True:
try:
mx = mx*mx
except MemoryError:
del mx
gc.collect()
assert i > 5
break
i += 1
resource.setrlimit(resource.RLIMIT_AS, (soft, hard))
test_square_outofmem()$ python b.py
RPython traceback:
File "pypy_objspace_std.c", line 25071, in W_IntObject_descr_mul
File "rpython_rlib.c", line 17439, in rbigint__toint_helper
File "rpython_rlib.c", line 15560, in rbigint__touint_helper
out of memory: couldn't allocate a few KB more
Aborted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.