Skip to content

threading.TIMEOUT_MAX integer overflow on 32-bit builds with threading.Thread.join #81846

Closed

Description

@ArunSharma
BPO 37665
Nosy @ZackerySpytz
Superseder
  • bpo-33632: undefined behaviour: signed integer overflow in threadmodule.c
  • Files
  • timeout_max_32_bit.py: Demonstration of timeout's immediate return
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-03-24.15:37:26.490>
    created_at = <Date 2019-07-23.23:42:44.565>
    labels = ['type-bug', '3.7']
    title = 'threading.TIMEOUT_MAX integer overflow on 32-bit builds with threading.Thread.join'
    updated_at = <Date 2022-03-24.15:37:26.489>
    user = 'https://bugs.python.org/ArunSharma'

    bugs.python.org fields:

    activity = <Date 2022-03-24.15:37:26.489>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-24.15:37:26.490>
    closer = 'iritkatriel'
    components = []
    creation = <Date 2019-07-23.23:42:44.565>
    creator = 'Arun Sharma'
    dependencies = []
    files = ['48501']
    hgrepos = []
    issue_num = 37665
    keywords = []
    message_count = 2.0
    messages = ['348358', '348361']
    nosy_count = 2.0
    nosy_names = ['ZackerySpytz', 'Arun Sharma']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '33632'
    type = 'behavior'
    url = 'https://bugs.python.org/issue37665'
    versions = ['Python 3.7']

    Activity

    1. ArunSharma commented on Jul 23, 2019

      ArunSharmamannequin
      MannequinAuthor

      threading's TIMEOUT_MAX constant causes overflows when used as the timeout for threading.Thread.join on a 32-bit platform, like a Raspberry PI running Raspbian (2019-07-10-raspbian-buster).

      The underlying code uses sem_timedwait. The timespec on this platform resolves seconds to a 32-bit integer, adding the current time to the timeout to get a deadline.

      ====

      >>> import threading
      >>> threading.TIMEOUT_MAX
      9223372036.0

      ====

      The deadline is larger than the int32 UNIX Epoch and results in an overflow.

      Just changing the threading.TIMEOUT_MAX to be based on the time left until the UNIX Epoch would require changing the timeout over the duration of the program and would not be very viable as the Epoch gets closer.

    2. ZackerySpytz commented on Jul 24, 2019

      ZackerySpytzmannequin
      Mannequin

      See also bpo-33632.

    3. transferred this issue fromon Apr 10, 2022
    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

      3.7 (EOL)end of lifetype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions