Skip to content

GH-108390: Prevent non-local events being set with sys.monitoring.set_local_events() #108420

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 8 commits into from
Sep 5, 2023

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Aug 24, 2023

PEP 669 refers to "local events" and implies strongly, if not explicitly stated, that only local events can be set locally.
But, the implementation allows non-local events, like RAISE, to be set locally.

This PR fixes that, which allows the crash reported in #108390 to be fixed as well.

Although a relatively large PR, as it will need backporting, it is really just splitting _Py_Monitors into _Py_LocalMonitors and _Py_GlobalMonitors and fixing the resulting compiler errors and warnings.

@markshannon markshannon changed the title GH-10839: Prevent non-local events being set with sys.monitoring.set_local_events() GH-108390: Prevent non-local events being set with sys.monitoring.set_local_events() Aug 24, 2023
@markshannon markshannon added the needs backport to 3.12 only security fixes label Aug 24, 2023
@markshannon
Copy link
Member Author

Also fixes #108470

@brandtbucher brandtbucher self-requested a review August 31, 2023 16:20
markshannon and others added 2 commits September 1, 2023 16:49
Co-authored-by: Radislav Chugunov <[email protected]>
Co-authored-by: Radislav Chugunov <[email protected]>
@markshannon markshannon merged commit 5a2a046 into python:main Sep 5, 2023
@miss-islington
Copy link
Contributor

Thanks @markshannon for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @markshannon, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 5a2a04615171899885b977d77dc379bd78bac87f 3.12

markshannon added a commit to faster-cpython/cpython that referenced this pull request Sep 5, 2023
markshannon added a commit to faster-cpython/cpython that referenced this pull request Sep 5, 2023
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot aarch64 RHEL8 LTO 3.x has failed when building commit 5a2a046.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/338/builds/4976) and take a look at the build logs.
  4. Check if the failure is related to this commit (5a2a046) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/338/builds/4976

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1000, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1096, in get_code
  File "<frozen importlib._bootstrap_external>", line 1195, in get_data
TypeError: descriptor 'close' for '_io.BufferedReader' objects doesn't apply to a '_io.FileIO' object


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto/build/Lib/threading.py", line 1059, in _bootstrap_inner
    self.run()
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto/build/Lib/threading.py", line 996, in run
    self._target(*self._args, **self._kwargs)
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto/build/Lib/test/test_interpreters.py", line 483, in task
    interp = interpreters.create()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.lto/build/Lib/test/support/interpreters.py", line 25, in create
    id = _interpreters.create(isolated=isolated)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: interpreter creation failed
k

markshannon added a commit to faster-cpython/cpython that referenced this pull request Sep 5, 2023
@bedevere-bot
Copy link

GH-108899 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Sep 5, 2023
Yhg1s pushed a commit that referenced this pull request Sep 5, 2023
…ring.set_local_events()` (GH-108420) (#108899)

* GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420)

* Restore generated objects

* Restore size of monitoring arrays in code object for 3.12 ABI compatibility.

* Update ABI file
@markshannon markshannon deleted the local-events-fix branch September 5, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants