Skip to content

PARI stack overflows when factoring at doc endpoint #129

@katestange

Description

@katestange

I'm not sure if this is related or different from #70 but on a fresh DB right now on my system, the endpoint http://127.0.0.1:5000/api/get_oeis_factors/A006862/50 from the documentation will cause the following error:

  ***   Warning: increasing stack size to 8003584.
/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/flaskr/nscope/views.py:301: RuntimeWarning: cypari2 leaked 8005128 bytes on the PARI stack
  seq = fetch_factors(valid_oeis_id, wants)
[2024-04-21 22:06:43,571] ERROR in app: Exception on /api/get_oeis_factors/A006862/50 [GET]
Traceback (most recent call last):
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask_cors/extension.py", line 176, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/flaskr/nscope/views.py", line 301, in get_oeis_factors
    seq = fetch_factors(valid_oeis_id, wants)
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/flaskr/nscope/views.py", line 182, in fetch_factors
    fac = gen_to_python(pari(val).factor())
  File "cypari2/gen.pyx", line 4363, in cypari2.gen.Gen.factor
  File "cypari2/handle_error.pyx", line 211, in cypari2.handle_error._pari_err_handle
cypari2.handle_error.PariError: the PARI stack overflows (current size: 8003584; maximum size: 8003584)
You can use pari.allocatemem() to change the stack size and try again
Exception on /api/get_oeis_factors/A006862/50 [GET]
Traceback (most recent call last):
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask_cors/extension.py", line 176, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/.venv/lib/python3.9/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/flaskr/nscope/views.py", line 301, in get_oeis_factors
    seq = fetch_factors(valid_oeis_id, wants)
  File "/home/katestange/data/projects/numberscope/frontscope-backscope/backscope/flaskr/nscope/views.py", line 182, in fetch_factors
    fac = gen_to_python(pari(val).factor())
  File "cypari2/gen.pyx", line 4363, in cypari2.gen.Gen.factor
  File "cypari2/handle_error.pyx", line 211, in cypari2.handle_error._pari_err_handle
cypari2.handle_error.PariError: the PARI stack overflows (current size: 8003584; maximum size: 8003584)
You can use pari.allocatemem() to change the stack size and try again
127.0.0.1 - - [21/Apr/2024 22:06:43] "GET /api/get_oeis_factors/A006862/50 HTTP/1.1" 500 -

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions