GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MemoryError and data race in devpoll selector on Solaris · Issue #102494 · python/cpython

MemoryError and data race in devpoll selector on Solaris #102494

New issue
Copy link
New issue
Copy link
Open
#102495
Open
MemoryError and data race in devpoll selector on Solaris#102494
#102495
Copy link
Labels
OS-unsupportedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-socketRelated to the socket, socketserver and selectors modulesRelated to the socket, socketserver and selectors modulestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kulikjak
kulikjak
opened on Mar 7, 2023
Issue body actions

There are currently two big issues with DevPoll selector on Solaris.

Memory Error

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.

Data race

There is a potential data race when multiple threads are operating on the same DevpollSelector; specifically when one thread is registering a new file object at the same time another one is polling. The issue is that the same struct pollfd buffer is used for both operations. Since sections around the OS calls have threads enabled, this can result in Python registering fd which just returned from the poll operation (rather than the one given), or vice versa.

Update: I added the second issue, which was not known when I originally filed this, but the attached PR fixes it as well.

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

  • gh-102494: fix MemoryError and data race in devpoll based selector on Solaris #102495

Activity

  1. kulikjak
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Mar 7, 2023
  2. kulikjak
    added a commit that references this issue on Mar 7, 2023

    pythongh-102494: fix MemoryError when using selectors on Solaris

    4cfa774
  3. arhadthedev
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Apr 2, 2023
  4. StanFromIreland
    added
    OS-unsupported
    on Jul 13, 2025
  5. github-project-automation
    added this to Unsupported platformson Jul 13, 2025
  6. kulikjak
    added a commit that references this issue on Jul 30, 2025

    pythongh-102494: fix MemoryError when using selectors on Solaris

    979dd2b
  7. kulikjak
    changed the title [-]MemoryError when using selectors on Solaris[/-] [+]MemoryError and data race in DevPoll selector on Solaris[/+] on May 19, 2026
  8. kulikjak
    changed the title [-]MemoryError and data race in DevPoll selector on Solaris[/-] [+]MemoryError and data race in devpoll selector on Solaris[/+] on May 19, 2026
  9. serhiy-storchaka
    added
    topic-socketRelated to the socket, socketserver and selectors modulesRelated to the socket, socketserver and selectors modules
    on Jul 3, 2026
  10. serhiy-storchaka
    assigned
    serhiy-storchaka
    and unassigned
    serhiy-storchaka
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-unsupportedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-socketRelated to the socket, socketserver and selectors modulesRelated to the socket, socketserver and selectors modulestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Unsupported platforms
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.