GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-98894: Fix `function__return` and `function__entry` dTrace probe missing after `GH-103083` by Zheaoli · Pull Request #125019 · python/cpython

Conversation

@Zheaoli

@Zheaoli Zheaoli commented Oct 6, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fix #98894

  • Issue: Some DTrace probes are broken in 3.11 #98894

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thesamesam, Decodetalkers, x-zvf, jschwinger233, cakemanny, and chenhengqi reacted with thumbs up emoji
All reactions
  • 👍 6 reactions
@Zheaoli
Zheaoli requested a review from markshannon as a code owner October 6, 2024 09:49
@bedevere-app bedevere-app Bot mentioned this pull request Oct 6, 2024
Some DTrace probes are broken in 3.11 #98894
Open
@bedevere-app bedevere-app Bot added the awaiting review label Oct 6, 2024
@Zheaoli

Zheaoli commented Oct 6, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

After #103083, the function__return and function__entry dTrace probe is missing. In the production environment, the developer may combine the dtrace probe with other tools like eBPF to trace the internal state of the CPython like

sudo bpftrace -e '                                                                         
usdt:/home/manjusaka/Documents/projects/cpython/python:python:function__return {
printf("filename: %s, funcname:%s, lineno:%d\n",str(arg0),str(arg1),arg2);
}
' -p 291832

And the function__return and function__entry part is still in the official document of the CPython for the Dtrace module.

So I think we should keep the codebase same with the document or we need to update the document if we confirm that we don't need the dtrace feature any more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Oct 6, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2024-10-06-17-46-24.gh-issue-98894.uG2s-h.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz approved these changes Oct 6, 2024
View reviewed changes
Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Oct 6, 2024
@picnixz

picnixz commented Oct 6, 2024

Copy link
Copy Markdown
Member

The build errors:

/tmp/tmpwuomaa14/_RETURN_VALUE.c:124:13: error: call to undeclared function 'PyDTrace_FUNCTION_RETURN_ENABLED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
124 | DTRACE_FUNCTION_EXIT();

Something is probably missing somewhere.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 6, 2024

Copy link
Copy Markdown
Contributor Author

The build errors:

/tmp/tmpwuomaa14/_RETURN_VALUE.c:124:13: error: call to undeclared function 'PyDTrace_FUNCTION_RETURN_ENABLED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
124 | DTRACE_FUNCTION_EXIT();

Something is probably missing somewhere.

I have noticed this, I'm working on the CI. Thanks for the tips. Draft this PR first

picnixz and Wulian233 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli
Zheaoli marked this pull request as draft October 6, 2024 11:20
@bedevere-app bedevere-app Bot removed the awaiting core review label Oct 6, 2024
Wulian233
Wulian233 approved these changes Oct 6, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 6, 2024
@Zheaoli
Zheaoli marked this pull request as ready for review October 6, 2024 14:20
@Zheaoli
Zheaoli requested a review from brandtbucher as a code owner October 6, 2024 14:20
@bedevere-app bedevere-app Bot added awaiting review and removed awaiting core review labels Oct 6, 2024
Zheaoli and others added 5 commits October 7, 2024 23:26
@Zheaoli
Fix function__return and function__entry dTrace probe missing aft…
f11b7c4
…er `pythonGH-103083`
@Zheaoli
Update news
ac683c0
@Zheaoli
Update generate case
b4d457f
@Zheaoli @picnixz
Update Misc/NEWS.d/next/Core_and_Builtins/2024-10-06-17-46-24.gh-issu…
4810510
…e-98894.uG2s-h.rst

Co-authored-by: Bénédikt Tran <[email protected]>
@Zheaoli
fix jit ci
128e856
@Zheaoli
Zheaoli force-pushed the manjusaka/fix-dtrace branch from 87ac00a to 128e856 Compare October 7, 2024 15:26
@markshannon

markshannon commented Oct 9, 2024

Copy link
Copy Markdown
Member

DTRACE_FUNCTION_ENTRY() and DTRACE_FUNCTION_EXIT() are static instrumentation points for dtrace, are they not?

IIUC, this means that they will not work with the JIT. Even if the instrumentation points are compiled into the templates, dtrace will not be able to find them.

How does dtrace handle jit-in-time compiled code?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 9, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

DTRACE_FUNCTION_ENTRY() and DTRACE_FUNCTION_EXIT() are static instrumentation points for dtrace, are they not?

Yes, it's static

IIUC, this means that they will not work with the JIT. Even if the instrumentation points are compiled into the templates, dtrace will not be able to find them.

How does dtrace handle jit-in-time compiled code?

The DTRACE_FUNCTION_ENTRY() and DTRACE_FUNCTION_EXIT() is not working in JIT mode. For now I just compile some empty function into the template to avoid the compile issue.

For now, the JIT is still an experimental feature. I think DTRACE_FUNCTION_ENTRY() and DTRACE_FUNCTION_EXIT() are still useful for normal code.

For the future, I think we may need extra dtrace point for JIT module

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Oct 10, 2024

Copy link
Copy Markdown
Member

For the future, I think we may need extra dtrace point for JIT module

How?
There's no point in adding back dtrace support for 3.14, if it stops working again in 3.15.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

How?

That would be some different dtrace points, I'm not sure we need to discuss it here.

There's no point in adding back dtrace support for 3.14, if it stops working again in 3.15.

I'm not sure about the JIT roadmap. if here's more than five years before we make the JIT default release, I think it still is worthed adding the dtrace point back.

Otherwise, we need to clean up the docs FYI https://docs.python.org/3/howto/instrumentation.html

thesamesam reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

@markshannon ping~

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thesamesam

thesamesam commented Oct 14, 2024

Copy link
Copy Markdown
Contributor

Also, merging it as it is facilitates backporting.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 22, 2024

Copy link
Copy Markdown
Contributor Author

@markshannon ping~

x-zvf reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Oct 23, 2024

Copy link
Copy Markdown
Member

I'm not sure about the JIT roadmap. if here's more than five years before we make the JIT default release, I think it still is worthed adding the dtrace point back.

The JIT will be included in 3.14, but probably off by default. It will almost certainly on by default for 3.15.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Oct 23, 2024

Copy link
Copy Markdown
Member

I'm not opposed to having dtrace hooks, but I don't see much value in them unless they

  • have tests (which means they built in by default, so CI can run the tests)
  • will work with the JIT
  • have very low overhead when not in use (should be true for the interpreter, but might not be for the JIT)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Oct 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I'm not opposed to having dtrace hooks, but I don't see much value in them unless they

  • have tests (which means they built in by default, so CI can run the tests)
  • will work with the JIT
  • have very low overhead when not in use (should be true for the interpreter, but might not be for the JIT)

OK, I got it. 1 and 3 would not be a big issue, but I need more time about 2. So how about we update https://docs.python.org/3/howto/instrumentation.html and remove the function__return and function__entry part first?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@x-zvf

x-zvf commented Mar 29, 2025

Copy link
Copy Markdown

+1
(bpf|d)trace instrumentation is an important feature for us. Is someone still working on it? If not, please add a note in the documentation that USDT probes are broken after python3.10, and users should avoid upgrading.

reffum reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@furkanonder

furkanonder commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

@Zheaoli Can you resolve the conflicts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Apr 4, 2025

Copy link
Copy Markdown
Contributor Author

@Zheaoli Can you resolve the conflicts?

Yes, But I think we need a final call here.

@markshannon Should we recover the USDT probe or we just need to remove it from documentation?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ajor

ajor commented Apr 23, 2025

Copy link
Copy Markdown

If the Python JIT can be enabled/disabled without a recompilation of Python, then to me it seems worth it to include this instrumentation for non-JIT codepaths at least.

That way, people who want instrumentation can disable the JIT to get it as needed. It can be documented that the probe points won't work when the JIT is enabled (rather than the alternative of them not working at all!)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@x-zvf

x-zvf commented Apr 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

If the Python JIT can be enabled/disabled without a recompilation of Python, then to me it seems worth it to include this instrumentation for non-JIT codepaths at least.

That way, people who want instrumentation can disable the JIT to get it as needed. It can be documented that the probe points won't work when the JIT is enabled (rather than the alternative of them not working at all!)

This seems like the easiest path to move forward with, but it defeats the greatest power of Dtrace - intrumenting running processes (with low overhead). If you need to restart a process to instrument it (disabling the jit), the probes become much less useful.
That said, this is still much preferable to removing the probes :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thesamesam

thesamesam commented Apr 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I'm also confident that I can get eyes on the general DTrace vs JIT issue in the future, just at the moment, the team working on that is busy with some more fundamental bits on the DTrace side. That is, I don't think this is delaying the inevitable or anything (and therefore PR should ideally go in for now).

x-zvf and reffum reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli
Merge branch 'main' of https://github.com/python/cpython into manjusa…
e98e3a2
…ka/fix-dtrace

Signed-off-by: Manjusaka <[email protected]>
@Zheaoli
Zheaoli requested a review from savannahostrowski as a code owner May 22, 2025 17:43
@Zheaoli

Zheaoli commented May 22, 2025

Copy link
Copy Markdown
Contributor Author

I think there are many people still need USDT for non-JIT build. I think this PR is still worth to push forward. I resolve the code conflict

furkanonder reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli

Zheaoli commented Sep 25, 2025

Copy link
Copy Markdown
Contributor Author

close this PR

cakemanny reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zheaoli Zheaoli closed this Sep 25, 2025
pablogsal added a commit to pablogsal/cpython that referenced this pull request Dec 8, 2025
@pablogsal
pythongh-98894: Restore function entry/exit DTrace probes
b1e8453
The function__entry and function__return probes stopped working in Python 3.11
when the interpreter was restructured around the new bytecode system. This change
restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label
in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE
instructions. The helper functions are defined in ceval.c and extract the
filename, function name, and line number from the frame before firing the probe.

This builds on the approach from python#125019
but avoids modifying the JIT template since the JIT does not currently support
DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops
otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW,
CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside
the existing SystemTap tests. Line probe tests were removed since that probe
was never restored after 3.11.
@pablogsal pablogsal mentioned this pull request Dec 8, 2025
gh-98894: Restore function entry/exit DTrace probes #142397
Merged
pablogsal added a commit to pablogsal/cpython that referenced this pull request Mar 20, 2026
@pablogsal
pythongh-98894: Restore function entry/exit DTrace probes
e48b2c1
The function__entry and function__return probes stopped working in Python 3.11
when the interpreter was restructured around the new bytecode system. This change
restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label
in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE
instructions. The helper functions are defined in ceval.c and extract the
filename, function name, and line number from the frame before firing the probe.

This builds on the approach from python#125019
but avoids modifying the JIT template since the JIT does not currently support
DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops
otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW,
CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside
the existing SystemTap tests. Line probe tests were removed since that probe
was never restored after 3.11.
pablogsal added a commit to pablogsal/cpython that referenced this pull request May 4, 2026
@pablogsal
pythongh-98894: Restore function entry/exit DTrace probes
f8b0571
The function__entry and function__return probes stopped working in Python 3.11
when the interpreter was restructured around the new bytecode system. This change
restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label
in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE
instructions. The helper functions are defined in ceval.c and extract the
filename, function name, and line number from the frame before firing the probe.

This builds on the approach from python#125019
but avoids modifying the JIT template since the JIT does not currently support
DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops
otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW,
CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside
the existing SystemTap tests. Line probe tests were removed since that probe
was never restored after 3.11.
pablogsal added a commit that referenced this pull request May 5, 2026
@pablogsal
gh-98894: Restore function entry/exit DTrace probes (#142397)
9a268e3
The function__entry and function__return probes stopped working in Python 3.11
when the interpreter was restructured around the new bytecode system. This change
restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label
in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE
instructions. The helper functions are defined in ceval.c and extract the
filename, function name, and line number from the frame before firing the probe.

This builds on the approach from #125019
but avoids modifying the JIT template since the JIT does not currently support
DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops
otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW,
CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside
the existing SystemTap tests. Line probe tests were removed since that probe
was never restored after 3.11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@picnixz picnixz picnixz approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@brandtbucher brandtbucher Awaiting requested review from brandtbucher brandtbucher is a code owner
@savannahostrowski savannahostrowski Awaiting requested review from savannahostrowski
+1 more reviewer
@Wulian233 Wulian233 Wulian233 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Some DTrace probes are broken in 3.11

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@Zheaoli @picnixz @markshannon @thesamesam @x-zvf @furkanonder @ajor @Wulian233
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.