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

Implement and document PEP 669. #103082

Closed
3 of 4 tasks
markshannon opened this issue Mar 28, 2023 · 10 comments
Closed
3 of 4 tasks

Implement and document PEP 669. #103082

markshannon opened this issue Mar 28, 2023 · 10 comments
Labels
3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member Author

Also needs to be added to the "What's new" and the PEP needs to be marked as accepted/final.

@AlexWaygood AlexWaygood added the 3.12 bugs and security fixes label Mar 31, 2023
@markshannon markshannon changed the title Implement PEP 669. Implement and document PEP 669. Apr 5, 2023
@markshannon
Copy link
Member Author

Specific things to document (that aren't clear from the PEP) (from comments by @gvanrossum):

event_set is a "set" constructed by OR-ing various events together (a common C idiom of course but not apparent until you see their integer values).

From GVR: "The naming of the CALL and RETURN/RAISE events is a bit confusing -- we have CALL (universal), C_RETURN/PY_RETURN (per language), but then C_RAISE and RAISE -- why isn't the latter PY_RAISE, just for consistency?"

There are good reasons for this design, so they should be documented.

markshannon added a commit that referenced this issue Apr 12, 2023
…on (GH-103083)

* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
markshannon added a commit that referenced this issue Apr 13, 2023
Turn on branch events for FOR_ITER instructions.
carljm added a commit to carljm/cpython that referenced this issue Apr 13, 2023
* main:
  pythongh-103479: [Enum] require __new__ to be considered a data type (pythonGH-103495)
  pythongh-103365: [Enum] STRICT boundary corrections (pythonGH-103494)
  pythonGH-103488: Use return-offset, not yield-offset. (pythonGH-103502)
  pythongh-103088: Fix test_venv error message to avoid bytes/str warning (pythonGH-103500)
  pythonGH-103082: Turn on branch events for FOR_ITER instructions. (python#103507)
  pythongh-102978: Fix mock.patch function signatures for class and staticmethod decorators (python#103228)
  pythongh-103462: Ensure SelectorSocketTransport.writelines registers a writer when data is still pending (python#103463)
  pythongh-95299: Rework test_cppext.py to not invoke setup.py directly (python#103316)
aisk pushed a commit to aisk/cpython that referenced this issue Apr 18, 2023
… CPython (pythonGH-103083)

* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
@pablogsal
Copy link
Member

pablogsal commented Apr 18, 2023

Seems that this PR (#103083) has broken the tracerefs buildbot:

https://buildbot.python.org/all/#/builders/484/builds/3091

@pablogsal
Copy link
Member

See also #103083 (comment)

markshannon pushed a commit that referenced this issue Apr 21, 2023
…H-103561)

Fix shifted field initialization in instrumentation.c
markshannon added a commit that referenced this issue May 12, 2023
…GH-104387)

When monitoring LINE events, instrument all instructions that can have a predecessor on a different line.
Then check that the a new line has been hit in the instrumentation code.
This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
carljm added a commit to carljm/cpython that referenced this issue May 12, 2023
* main:
  pythongh-91896: Fixup some docs issues following ByteString deprecation (python#104422)
  pythonGH-104371: check return value of calling `mv.release` (python#104417)
  pythongh-104415: Fix refleak tests for `typing.ByteString` deprecation (python#104416)
  pythonGH-86275: Implementation of hypothesis stubs for property-based tests, with zoneinfo tests (python#22863)
  pythonGH-103082: Filter LINE events in VM, to simplify tool implementation. (pythonGH-104387)
  pythongh-93649: Split gc- and allocation tests from _testcapimodule.c (pythonGH-104403)
  pythongh-104389: Add 'unused' keyword to Argument Clinic C converters (python#104390)
  pythongh-101819: Prepare _io._IOBase for module state (python#104386)
  pythongh-104413: Fix refleak when super attribute throws AttributeError (python#104414)
  Fix refleak in `super_descr_get` (python#104408)
  pythongh-87526: Remove dead initialization from _zoneinfo parse_abbr() (python#24700)
  pythongh-91896: Improve visibility of `ByteString` deprecation warnings (python#104294)
  pythongh-104371: Fix calls to `__release_buffer__` while an exception is active (python#104378)
  pythongh-104377: fix cell in comprehension that is free in outer scope (python#104394)
  pythongh-104392: Remove _paramspec_tvars from typing (python#104393)
  pythongh-104396: uuid.py to skip platform check for emscripten and wasi (pythongh-104397)
  pythongh-99108: Refresh HACL* from upstream (python#104401)
  pythongh-104301: Allow leading whitespace in disambiguated pdb statements (python#104342)
@jpe
Copy link

jpe commented Jul 13, 2023

Is there any way to get the active exception from a PY_UNWIND event callback? I was hoping the exception would be passed to the callback but it isn't. This was an issue with the old tracer function debugger / profiler support so it's not really a regression, but I was hoping to avoid the work arounds that we used with it.

Note the the signature for several of the events aren't specified -- including PY_UNWIND and EXCEPTION_HANDLED. They're easily enough determined (though my guess was wrong for PY_UNWIND), but it would be better if they were documented.

@jpe
Copy link

jpe commented Jul 14, 2023

It looks like returning DISABLE from a handler for an event >= PY_MONITORING_INSTRUMENTED_EVENTS triggers an assert in a debug build. It would probably be better to just ignore a DISABLE return value since anything else can be returned (I think) or mandate that None be returned. If the current behavior is retained, it should be documented.

Please let me know if you want me to open separate bugs for this and for other sys.monitoring issues. Otherwise, I'lll add to this bug.

@jpe
Copy link

jpe commented Jul 14, 2023

An exception raised in a EXCEPTION_HANDLED callback triggers an assert in a debug build of 3.12b4. I was using the following incorrect signature for a callback method and registering it as a bound method --

def _py_handled_event(self, instruction_offset: int, exception: BaseException):

This was my mistake (it was a simple oversight while editing) but it the calling code should handle the exception without crashing.

@jpe
Copy link

jpe commented Jul 14, 2023

It looks like no RAISE event is emitted for a bare raise in an except: clause or at the end of a finally: clause that implicitly reraises an exception. I don't know whether this a problem with the implementation or it should simply be documented that this is to be expected. My use case is to track what exception is active so it's available to an unwind handler.

@carljm
Copy link
Member

carljm commented Jul 18, 2023

@jpe I think opening a new issue for each separable problem will make these easier to track and triage, and less likely they'll fall through the cracks.

vstinner added a commit that referenced this issue Jul 22, 2023
)

Rename private C API constants:

* Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS
* Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
vstinner added a commit to vstinner/cpython that referenced this issue Jul 22, 2023
…python#107069)

Rename private C API constants:

* Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS
* Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS

(cherry picked from commit 0927a2b)
vstinner added a commit that referenced this issue Jul 22, 2023
#107069) (#107075)

GH-103082: Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS (#107069)

Rename private C API constants:

* Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS
* Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS

(cherry picked from commit 0927a2b)
jtcave pushed a commit to jtcave/cpython that referenced this issue Jul 23, 2023
…python#107069)

Rename private C API constants:

* Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS
* Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
mementum pushed a commit to mementum/cpython that referenced this issue Jul 23, 2023
…python#107069)

Rename private C API constants:

* Rename PY_MONITORING_UNGROUPED_EVENTS to _PY_MONITORING_UNGROUPED_EVENTS
* Rename PY_MONITORING_EVENTS to _PY_MONITORING_EVENTS
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 11, 2023
iritkatriel added a commit that referenced this issue Aug 14, 2023
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 15, 2023
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 16, 2023
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Aug 16, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 5, 2023
Yhg1s pushed a commit that referenced this issue Sep 5, 2023
…GH-107772) (#108909)

GH-103082: Document PEP-669: Low Impact Monitoring for CPython (GH-107772)
(cherry picked from commit 8b515f6)

Co-authored-by: Mark Shannon <[email protected]>
@AA-Turner
Copy link
Member

Is this issue now complete given #107772?

brandtbucher pushed a commit to brandtbucher/cpython that referenced this issue Oct 18, 2023
brandtbucher added a commit that referenced this issue Oct 18, 2023
@iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

7 participants