Sitelet https://web.archive.org/web/20240815075541/https://github.com/python/cpython/issues/121474
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

Barrier hangs indefinitely when arg parties < 0 or invalid type #121474

Closed
pygeek opened this issue Jul 8, 2024 · 3 comments
Closed

Barrier hangs indefinitely when arg parties < 0 or invalid type #121474

pygeek opened this issue Jul 8, 2024 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@pygeek
Copy link
Contributor

pygeek commented Jul 8, 2024 •

Bug report

Bug description:

threading.Barrier at no point checks for valid parties. parties, of a negative value, or invalid type hang indefinitely on .wait(). This behavior is inconsistent from the behavior of any other threading primitives, which either conduct sanity checks on args during initialization, or fail at some point in their execution.

Steps to reproduce:

from threading import Barrier
# negative
barrier = Barrier(-1) # <threading.Barrier at 0x10aa789b0: waiters=0/-1>
barrier.wait()

# invalid type string
barrier = Barrier("test") # <threading.Barrier at 0x10ae64980: waiters=0/test>
barrier.wait()

# invalid type float
barrier = Barrier(0.5) # <threading.Barrier at 0x10aa7a570: waiters=0/0.5>
barrier.wait()

# invalid type object
barrier = Barrier(object()) # <threading.Barrier at 0x10ae4f500: waiters=0/<object object at 0x10a878730>>
barrier.wait()

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

@pygeek pygeek added the type-bug An unexpected behavior, bug, or error label Jul 8, 2024
@pygeek pygeek changed the title Barrier hangs indefinitely when arg parties < 0 Barrier hangs indefinitely when arg parties < 0 or invalid type Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
@graingert
Copy link
Contributor

graingert commented Jul 8, 2024 •

asyncio.Barrier has this validation https://github.com/python/cpython/blob/3.12/Lib/asyncio/locks.py#L457

@pygeek
Copy link
Contributor Author

pygeek commented Jul 8, 2024 •

https://github.com/python/cpython/blob/3.12/Lib/asyncio/locks.py#L457

This issue is not related to async.Barrier. This is a bug in threading.Barrier

https://github.com/python/cpython/blob/3.12/Lib/threading.py#L670

@graingert
Copy link
Contributor

graingert commented Jul 8, 2024 •

https://github.com/python/cpython/blob/3.12/Lib/asyncio/locks.py#L457

This issue is not related to async.Barrier. This is a bug in threading.Barrier

https://github.com/python/cpython/blob/3.12/Lib/threading.py#L670

I'm aware. My point is that asyncio.Barrier has this validation so threading.Barrier should have it also

pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 8, 2024
pygeek added a commit to pygeek/cpython that referenced this issue Jul 10, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 30, 2024
…honGH-121480)

(cherry picked from commit d27a53f)

Co-authored-by: Clinton <pygeek@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 30, 2024
…honGH-121480)

(cherry picked from commit d27a53f)

Co-authored-by: Clinton <pygeek@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this issue Jul 30, 2024
…-121480) (GH-122443)

(cherry picked from commit d27a53f)

Co-authored-by: Clinton <pygeek@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this issue Jul 30, 2024
…-121480) (GH-122444)

(cherry picked from commit d27a53f)

Co-authored-by: Clinton <pygeek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants