Bug 470121

Summary: Can't run callgrind_control with valgrind 3.21.0 because of perl errors
Product: [Developer tools] valgrind Reporter: Romain Geissler <romain.geissler>
Component: callgrindAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal CC: mark, pjfloyd
Priority: NOR    
Version First Reported In: 3.21.0   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Patch workarounding the issue (ie remove "use strict;")
More complete patch
Full patch with a few fixes

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