Bug 2217490 - callgrind Python scripts not working on RHEL-8.9
Summary: callgrind Python scripts not working on RHEL-8.9
Keywords:
Status: VERIFIED
Alias: None
Deadline: 2023-07-03
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: valgrind
Version: 8.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Mark Wielaard
QA Contact: Jesus Checa
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-26 12:22 UTC by Jesus Checa
Modified: 2023-06-28 09:54 UTC (History)
3 users (show)

Fixed In Version: valgrind-3.21.0-8.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-160766 0 None None None 2023-06-26 12:25:01 UTC
Red Hat Issue Tracker RHELPLAN-160767 0 None None None 2023-06-26 12:25:05 UTC

Description Jesus Checa 2023-06-26 12:22:50 UTC
Description of problem:
callgrind scripts (cg_annotate, cg_merge, cg_diff) were rewritten as Python scripts for valgrind 3.21 release. These include features such as type annotations and the new walrus operator which are supported only in Python versions 3.7 and 3.8 respectively.

This causes several issues when running cg_* scripts because RHEL-8 ships Python 3.6 as default, for example:
  File "../cg_annotate", line 449
    while line := readline():
                ^
SyntaxError: invalid syntax

Version-Release number of selected component (if applicable):
valgrind-3.21.0-3.el8

How reproducible:
100%

Steps to Reproduce:
1. cg_annotate --version
2. cg_merge --version
3. cg_diff --version

Actual results:
# cg_annotate --version
  File "/usr/bin/cg_annotate", line 449
    while line := readline():
                ^
SyntaxError: invalid syntax
# cg_merge --version
  File "/usr/bin/cg_merge", line 164
    while line := readline():
                ^
SyntaxError: invalid syntax
# cg_diff --version
  File "/usr/bin/cg_diff", line 218
    while line := readline():
                ^
SyntaxError: invalid syntax

Comment 1 Jesus Checa 2023-06-26 12:55:30 UTC
It seems that the scripts also use the "BooleanOptionalAction" action from the argparse module, which is available from Python 3.9. If we try to run the scripts with python38 (to cover the support of annotations and walrus operator), we get the following traceback:
# cg_annotate --version                                                                                                                                                                                                                                 
Traceback (most recent call last):                                                                                                                                                                                                                                              
  File "/usr/bin/cg_annotate", line 41, in <module>                                                                                                                                                                                                                             
    from argparse import ArgumentParser, BooleanOptionalAction, Namespace                                                                                                                                                                                                       
ImportError: cannot import name 'BooleanOptionalAction' from 'argparse' (/usr/lib64/python3.8/argparse.py)

Comment 2 Mark Wielaard 2023-06-27 09:34:12 UTC
The solution is easy, just add BuildRequires for python39 and python39-rpm-macros this will make sure the testsuite is run with python3.9 as python3 and the rpm-macros will adjust the installed scripts to use #!/usr/bin/python3.9 (and add a Requires for that to the package).

Comment 3 Mark Wielaard 2023-06-27 10:45:00 UTC
Looks like python39 is a "module" and so cannot be easily used as BuildRequires.
But we can use python3.11 since that is newer and isn't a module.

Comment 4 Jesus Checa 2023-06-28 06:11:52 UTC
Gating tests are all passing.

Tested valgrind-3.21.0-8.el8: the python scripts now work as expected. The "Sanity/valgrind-scripts-smoke" testcase passes with this new build, while fails with previous valgrind-3.21.0-7.el8 build. Additionally there are no more "post check failures" in the %check rpmbuild testsuite in the tests that involved cg_merg, cg_diff and cg_annotate scripts.


Note You need to log in before you can comment on or make changes to this bug.