Bug 470121 - Can't run callgrind_control with valgrind 3.21.0 because of perl errors
Summary: Can't run callgrind_control with valgrind 3.21.0 because of perl errors
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: callgrind (other bugs)
Version First Reported In: 3.21.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-22 11:48 UTC by Romain Geissler
Modified: 2023-06-09 11:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Patch workarounding the issue (ie remove "use strict;") (1.87 KB, application/x-perl)
2023-05-22 11:48 UTC, Romain Geissler
Details
More complete patch (4.30 KB, patch)
2023-05-31 08:20 UTC, Paul Floyd
Details
Full patch with a few fixes (4.10 KB, patch)
2023-06-08 15:03 UTC, Paul Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Romain Geissler 2023-05-22 11:48:44 UTC
Created attachment 159185 [details]
Patch workarounding the issue (ie remove "use strict;")

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

STEPS TO REPRODUCE
1. Just run `callgrind_control --help` with valgrind 3.21, you will see it cannot run because of some perl errors. Errors are of two types:
- Global symbol "$c" requires explicit package name at ./callgrind_control line 502.
- Bareword "getCallgrindPids" not allowed while "strict subs" in use at ./callgrind_control line 220.

OBSERVED RESULT
Perl errors.


EXPECTED RESULT
No perl errors.


SOFTWARE/OS VERSIONS
Tried on SLES 12 and RHEL 9.

ADDITIONAL INFORMATION
I add this this bug report a git commit which workarounds (ie remove "use strict;", not fix the actual errors) this issue. I hardly know anything about perl ;) A better long term fix would be to actually fix these perl errors.
Comment 1 Paul Floyd 2023-05-24 14:29:06 UTC
> ADDITIONAL INFORMATION
> I add this this bug report a git commit which workarounds (ie remove "use
> strict;", not fix the actual errors) this issue. I hardly know anything
> about perl ;) A better long term fix would be to actually fix these perl
> errors.

I'm equally bad at perl, but it looks like it just wants all variables to be properly declared with "my".

Hope to have a fix ready soon.
Comment 2 Mark Wielaard 2023-05-30 21:53:55 UTC
Urgh, that is my fault:

commit 6fc239ed47b44b82fb14849159f5b22132b6ca94
Author: Mark Wielaard <mark@klomp.org>
Date:   Fri Apr 21 18:13:14 2023 +0200

    Add use strict and use warnings to perl callgrind scripts
    
    This way we can simply use #! /usr/bin/env perl and don't need env -S
    and perl -w flags which might confuse some packaging utilities.

But I clearly never tested callgrind_control and it also doesnt seem to have any tests (callgrind_annotate, the other perl script does have two tests callgrind/tests/ann{1,2}.vgtest).

I quickly tested by hand and simply removing use strict seems to make everything work as expected.
So unless it is really easy to make the perl script "strict" I would recommend going with simply removing the use strict;
Comment 3 Paul Floyd 2023-05-31 08:20:29 UTC
Created attachment 159364 [details]
More complete patch

Only tested with callgrind_control -help
Comment 4 Paul Floyd 2023-05-31 08:21:31 UTC
Perhaps we should add some tests as well.
Comment 5 Paul Floyd 2023-06-08 10:28:19 UTC
The patch needs a bit more work. I've fixed one problem, but the -e option doesn't seem to be working.
Comment 6 Paul Floyd 2023-06-08 10:43:44 UTC
(In reply to Paul Floyd from comment #5)
> The patch needs a bit more work. I've fixed one problem, but the -e option
> doesn't seem to be working.

Have mostly fixed -e but still getting two Ir columns.
Comment 7 Paul Floyd 2023-06-08 15:03:49 UTC
Created attachment 159540 [details]
Full patch with a few fixes

There were a few bugs like variables not being reinitialized.
Comment 8 Paul Floyd 2023-06-09 11:46:09 UTC
commit 3df8a00a4ed7dbe436f28d8b3db72e679eb1b427 (origin/master, origin/HEAD, master)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Fri Jun 9 13:17:58 2023 +0200

    470121 - Can't run callgrind_control with valgrind 3.21.0 because of perl errors