-
Notifications
You must be signed in to change notification settings - Fork 19
posix, signal: posix_spawn's keyword arguments, setgroups, sched_param, and the signal mask the interpreter thread was clearing #1359
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e05a41a
module: add the _statistics and _types builtin modules
youknowone dc63bac
_lzma, _bz2: raise on a decompress cap the index type cannot hold
youknowone 58405d7
_lsprof: convert enable's flag arguments before claiming the tool id
youknowone a977e1c
module: add _queue with a native SimpleQueue
youknowone c0c99bd
interpreter: push opcode results onto the anchored frame
youknowone 8f4fe4d
posix: implement the posix_spawn keyword arguments and widen the devi…
youknowone d3d8070
signal: keep the inherited mask blocked on the interpreter thread
youknowone 9281b2e
signal: drop the handlers at teardown and report a signal left withou…
youknowone 28275ea
posix: implement setgroups
youknowone 18cfd60
posix: resolve link's follow_symlinks through linkat on both answers
youknowone db64715
host_seam: export SCHED_NORMAL, SCHED_DEADLINE and SCHED_RESET_ON_FORK
youknowone 1cf7125
posix: read and write the group list through host_env off the apple t…
youknowone 2581ca6
posix: name sched_param's argument and give it its own __reduce__
youknowone bb2d08f
posix: keep sched_param's cls positional-only
youknowone 4929b6d
bench/synth: re-record two wasm loops_compiled baselines
youknowone 8c26738
signal: return without a trace when a signal has no callable handler
youknowone 144d1c7
_queue, _statistics: match the arguments each accelerator validates
youknowone 32e5ea2
posix: root what sched_param and file_actions hold across allocating …
youknowone dd17a37
interpreter: anchor GET_ITER's push and confine FrameAnchor to its th…
youknowone f893bb3
_queue: let SimpleQueue.put bind block and timeout by keyword
youknowone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
pyre/extra_tests/parity_tests/lsprof_enable_frees_tool_id_on_failure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # CPython-suite gap: test_cprofile and test_profile only ever pass real bools | ||
| # to `enable`, so neither exercises the failing-conversion path, and the leak | ||
| # they would expose is process-wide rather than per-test. | ||
| # parity-tests reason: the tool id is a process singleton, so the damage shows | ||
| # up on a *later, unrelated* profiler; that cross-object effect is what this | ||
| # checks, on both backends, on every leg. | ||
|
|
||
| """A failed `Profiler.enable` must not keep the profiler tool id. | ||
|
|
||
| `enable` takes `subcalls` and `builtins` through the index/bool protocol, so | ||
| an argument whose `__bool__` raises makes the call fail. The tool id is a | ||
| single process-wide slot: if the failed call has already claimed it and | ||
| nothing releases it, `disable` cannot help -- it is a no-op while the | ||
| profiler never became enabled -- and every later `enable`, on any profiler | ||
| object, reports that another tool is active. | ||
|
|
||
| The discriminator is therefore a *second, independent* profiler enabling | ||
| successfully after the first one's `enable` raised. | ||
| """ | ||
|
|
||
| import _lsprof | ||
|
|
||
|
|
||
| class Raises: | ||
| def __bool__(self): | ||
| raise ValueError("no truth value") | ||
|
|
||
|
|
||
| def main(): | ||
| first = _lsprof.Profiler() | ||
| try: | ||
| first.enable(Raises()) | ||
| except ValueError: | ||
| pass | ||
| else: | ||
| raise AssertionError("enable() accepted an argument whose __bool__ raises") | ||
|
|
||
| # The failed call must have left the tool id free. | ||
| second = _lsprof.Profiler() | ||
| second.enable() | ||
| second.disable() | ||
|
|
||
| # And the id must still be reusable after a clean enable/disable pair. | ||
| third = _lsprof.Profiler() | ||
| third.enable() | ||
| third.disable() | ||
|
|
||
| print("OK") | ||
|
|
||
|
|
||
| main() |
73 changes: 73 additions & 0 deletions
73
pyre/extra_tests/parity_tests/simplequeue_put_defaults_replay.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # CPython-suite gap: test_queue reaches this only through | ||
| # `CSimpleQueueTest.test_reentrancy`, which reads as a finalizer-ordering test | ||
| # and reports it as a 10000-element list diff -- it names neither the replayed | ||
| # call nor the argument shape that causes it. | ||
| # parity-tests reason: the defect is a miscompile, so it needs a fixture that | ||
| # runs the loop hot on both backends and checks a count that the interpreter | ||
| # and the compiled trace must agree on. | ||
|
|
||
| """A hot loop must call its producer exactly once per iteration. | ||
|
|
||
| `SimpleQueue.put` is declared `put(item, block=True, timeout=None)`; the two | ||
| trailing arguments are accepted and ignored, because an unbounded queue never | ||
| blocks. Writing `put(v)` therefore leaves the call site to fill both defaults | ||
| in, and that is the shape this guards. | ||
|
|
||
| When such a call is compiled into a hot loop, the call feeding it must not be | ||
| re-executed. `Counter.next` is deliberately side-effecting, so a replay shows | ||
| up twice over: as a producer count that exceeds the iteration count, and as a | ||
| value that is generated but never queued -- which shifts every later result by | ||
| one rather than reordering a pair. | ||
|
|
||
| A plain function call in the producer position does not reproduce it; the call | ||
| has to go through the method path, which is why this uses a bound method. | ||
|
|
||
| The count is small enough to stay fast and large enough for the loop to be | ||
| compiled and left at least once. | ||
| """ | ||
|
|
||
| import queue | ||
|
|
||
| LIMIT = 1500 | ||
|
|
||
|
|
||
| class Counter: | ||
| def __init__(self): | ||
| self.n = 0 | ||
|
|
||
| def next(self): | ||
| value = self.n | ||
| self.n += 1 | ||
| return value | ||
|
|
||
|
|
||
| def main(): | ||
| q = queue.SimpleQueue() | ||
| counter = Counter() | ||
| results = [] | ||
|
|
||
| while True: | ||
| q.put(counter.next()) | ||
| results.append(q.get()) | ||
| if results[-1] >= LIMIT: | ||
| break | ||
|
|
||
| assert counter.n == len(results), ( | ||
| "the producer ran more often than the loop body", | ||
| counter.n, | ||
| len(results), | ||
| ) | ||
| expected = list(range(LIMIT + 1)) | ||
| assert results == expected, ( | ||
| "a produced value never reached the queue", | ||
| next( | ||
| (i, results[i], expected[i]) | ||
| for i in range(len(results)) | ||
| if results[i] != expected[i] | ||
| ), | ||
| ) | ||
|
|
||
| print("OK") | ||
|
|
||
|
|
||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add the required
__init__return annotation.Ruff reports ANN204 on Line 35. Add
-> Noneto keep this test file lint-clean.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.16.1)
[warning] 35-35: Missing return type annotation for special method
__init__Add return type annotation:
None(ANN204)
🤖 Prompt for AI Agents
Source: Linters/SAST tools