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

Pickling a range iterator with an index of over sizeof(int) stores an invalid index #89181

Closed
ambv opened this issue Aug 26, 2021 · 4 comments
Closed
Labels
3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes type-bug An unexpected behavior, bug, or error

Comments

@ambv
Copy link
Contributor

ambv commented Aug 26, 2021

BPO 45018
Nosy @ambv, @miss-islington, @chilaxan
PRs
  • bpo-45018: Fix rangeiter_reduce in rangeobject.c #27938
  • [3.10] bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938) #27990
  • [3.9] bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938) #27991
  • 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 2021-08-28.18:56:58.899>
    created_at = <Date 2021-08-26.16:42:14.034>
    labels = ['type-bug', '3.9', '3.10', '3.11']
    title = 'Pickling a range iterator with an index of over sizeof(int) stores an invalid index'
    updated_at = <Date 2021-08-28.18:56:58.898>
    user = 'https://github.com/ambv'

    bugs.python.org fields:

    activity = <Date 2021-08-28.18:56:58.898>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-28.18:56:58.899>
    closer = 'lukasz.langa'
    components = []
    creation = <Date 2021-08-26.16:42:14.034>
    creator = 'lukasz.langa'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45018
    keywords = ['patch']
    message_count = 4.0
    messages = ['400360', '400409', '400411', '400489']
    nosy_count = 3.0
    nosy_names = ['lukasz.langa', 'miss-islington', 'chilaxan']
    pr_nums = ['27938', '27990', '27991']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45018'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @ambv
    Copy link
    Contributor Author

    ambv commented Aug 26, 2021

    Consider the following:

    >>> it = iter(range(2**32 + 2))
    >>> for _ in range(2**32):
    ...   _ = next(it)
    >>> it2 = pickle.loads(
    ...   pickle.dumps(it)
    ... )
    >>> assert next(it) == next(it2)

    This assert currently fails because the reduce method for range iterator objects serializes to int instead of long.

    (note that running this example might take tens of minutes on your box)

    @ambv ambv added 3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes type-bug An unexpected behavior, bug, or error labels Aug 26, 2021
    @ambv
    Copy link
    Contributor Author

    ambv commented Aug 27, 2021

    New changeset 94a3d2a by chilaxan in branch 'main':
    bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)
    94a3d2a

    @ambv
    Copy link
    Contributor Author

    ambv commented Aug 27, 2021

    New changeset 0243764 by Miss Islington (bot) in branch '3.9':
    bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938) (GH-27991)
    0243764

    @miss-islington
    Copy link
    Contributor

    New changeset cd986e9 by Miss Islington (bot) in branch '3.10':
    bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)
    cd986e9

    @ambv ambv closed this as completed Aug 28, 2021
    @ambv ambv closed this as completed Aug 28, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants