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

MemoryError when using selectors on Solaris #102494

Open
kulikjak opened this issue Mar 7, 2023 · 0 comments · May be fixed by #102495
Open

MemoryError when using selectors on Solaris #102494

kulikjak opened this issue Mar 7, 2023 · 0 comments · May be fixed by #102495
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@kulikjak
Copy link
Contributor

kulikjak commented Mar 7, 2023

If you set ulimit -n unlimited on Solaris and its derivatives (where /dev/poll is available) and import selectors, Python crashes with a MemoryError:

> ulimit -n unlimited
> python3.11 -c "import selectors"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/selectors.py", line 613, in <module>
    elif _can_use('devpoll'):
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/selectors.py", line 594, in _can_use
    selector_obj = selector()
                   ^^^^^^^^^^
MemoryError

The issue is that Python uses RLIMIT_NOFILE to allocated that many struct pollfds, and there is no upper limit. Infinity is represented by something close to INT_MAX, and the allocation thus fails.

Your environment

I tested this on Oracle Solaris with 3.11, 3.9 and 3.7 (where you need a slightly different way to crash it: python3.7 -c "import select; select.devpoll()").

I verified that on SmartOS, it behaves the same way (on SmartOS, you can actually set huge ulimit -n values that break it as well).

Linked PRs

@kulikjak kulikjak added the type-bug An unexpected behavior, bug, or error label Mar 7, 2023
kulikjak added a commit to kulikjak/cpython that referenced this issue Mar 7, 2023
@arhadthedev arhadthedev added the stdlib Python modules in the Lib dir label Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants