Bug 2177062

Summary: python3.11: systemtap probe python.function.entry doesn't work
Product: Red Hat Enterprise Linux 9 Reporter: Lukáš Zachar <lzachar>
Component: python3.11Assignee: Tomas Orsava <torsava>
Status: NEW --- QA Contact: Lukáš Zachar <lzachar>
Severity: unspecified Docs Contact:
Priority: low    
Version: 9.2CC: mcermak, torsava
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Lukáš Zachar 2023-03-09 20:19:58 UTC
Description of problem:

Probe 'python.function.entry' doesn't fire when used with python3.11, the older versions do.

Version-Release number of selected component (if applicable):
python3.11-3.11.2-2.el9

How reproducible:
always

Steps to Reproduce:
1. create script.py with:
  import random, time
  print(random.random())
  time.sleep(3)

2. create probe.stp with:
   #!/usr/bin/stap -v
   probe python.function.entry
   {
     if ( filename =~ "random" )
       printf("%s => %s in %s:%d\n", thread_indent(1), funcname, filename, lineno);
   }

3. stap probe.stp -v -c "python3.11 script.py"

Actual results:
just random integer printed

Expected results:
output from python3.8 is like
  3649 python3.8(61912):  => Random in /usr/lib64/python3.8/random.py:78
  3677 python3.8(61912):   => SystemRandom in /usr/lib64/python3.8/random.py:709
  3694 python3.8(61912):    => __init_subclass__ in /usr/lib64/python3.8/random.py:103
  3705 python3.8(61912):     => __init__ in /usr/lib64/python3.8/random.py:94
  3707 python3.8(61912):      => seed in /usr/lib64/python3.8/random.py:123


Additional info:

Comment 2 Miro Hrončok 2023-03-12 20:25:47 UTC
I can reproduce the difference on Fedora:

$ sudo stap probe.stp -v -c "python3.11 script.py"
Pass 1: parsed user script and 535 library scripts using 575376virt/332460res/15484shr/316708data kb, in 490usr/80sys/566real ms.
Pass 2: analyzed script: 11 probes, 14 functions, 2 embeds, 2 globals using 608656virt/357412res/19124shr/349988data kb, in 110usr/10sys/117real ms.
Pass 3: translated to C into "/tmp/stape4dZII/stap_9fa553ac31a31de18203ad90492e581a_12144_src.c" using 608672virt/369488res/19612shr/350004data kb, in 100usr/90sys/192real ms.
Pass 4: compiled C into "stap_9fa553ac31a31de18203ad90492e581a_12144.ko" in 1760usr/390sys/1988real ms.
Pass 5: starting run.
0.246567578357341
Pass 5: run completed in 30usr/60sys/3431real ms.


$ sudo stap probe.stp -v -c "python3.10 script.py"
Pass 1: parsed user script and 535 library scripts using 575376virt/332400res/15424shr/316708data kb, in 490usr/70sys/562real ms.
Pass 2: analyzed script: 11 probes, 14 functions, 2 embeds, 2 globals using 608656virt/357372res/19084shr/349988data kb, in 110usr/0sys/115real ms.
Pass 3: translated to C into "/tmp/stapsfa1kk/stap_960a509d59f42ecc5fdfe3e95b6e8abd_12144_src.c" using 608672virt/369440res/19564shr/350004data kb, in 110usr/90sys/198real ms.
Pass 4: compiled C into "stap_960a509d59f42ecc5fdfe3e95b6e8abd_12144.ko" in 1800usr/440sys/2073real ms.
Pass 5: starting run.
     0 python3.10(3588962): => <module> in /usr/lib64/python3.10/random.py:1
0.9428721885880854
  3159 python3.10(3588962):  => Random in /usr/lib64/python3.10/random.py:103
  3179 python3.10(3588962):   => SystemRandom in /usr/lib64/python3.10/random.py:813
  3192 python3.10(3588962):    => __init_subclass__ in /usr/lib64/python3.10/random.py:219
  3207 python3.10(3588962):     => __init__ in /usr/lib64/python3.10/random.py:119
  3208 python3.10(3588962):      => seed in /usr/lib64/python3.10/random.py:128
Pass 5: run completed in 20usr/70sys/3443real ms.


$ sudo stap probe.stp -v -c "python3.9 script.py"
Pass 1: parsed user script and 535 library scripts using 575376virt/332424res/15448shr/316708data kb, in 520usr/80sys/601real ms.
Pass 2: analyzed script: 11 probes, 14 functions, 2 embeds, 2 globals using 608656virt/357448res/19160shr/349988data kb, in 120usr/0sys/123real ms.
Pass 3: translated to C into "/tmp/stapQ3UJLx/stap_0c04ce72ddc21345525440096a38419c_12143_src.c" using 608672virt/369556res/19680shr/350004data kb, in 110usr/100sys/212real ms.
Pass 4: compiled C into "stap_0c04ce72ddc21345525440096a38419c_12143.ko" in 1740usr/320sys/1886real ms.
Pass 5: starting run.
     0 python3.9(3589395): => <module> in /usr/lib64/python3.9/random.py:1
0.41255422987101886
  3231 python3.9(3589395):  => Random in /usr/lib64/python3.9/random.py:101
  3251 python3.9(3589395):   => SystemRandom in /usr/lib64/python3.9/random.py:778
  3264 python3.9(3589395):    => __init_subclass__ in /usr/lib64/python3.9/random.py:217
  3274 python3.9(3589395):     => __init__ in /usr/lib64/python3.9/random.py:117
  3276 python3.9(3589395):      => seed in /usr/lib64/python3.9/random.py:126
Pass 5: run completed in 10usr/60sys/3439real ms.

Comment 3 Martin Cermak 2023-03-20 09:17:41 UTC
I think this is a possible dupe of https://bugzilla.redhat.com/show_bug.cgi?id=2152970 .

Comment 4 Tomas Orsava 2023-08-09 12:20:10 UTC
There is some movement on the upstream issue [0], let's wait on what develops. We currently don't have the resources to address the issue downstream.

[0] https://github.com/python/cpython/issues/104280