Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: NYTProf line report failure

by swl (Parson)
on Mar 10, 2020 at 21:36 UTC ( [id://11114102]=note: print w/replies, xml ) Need Help??


in reply to NYTProf line report failure

Which version of Devel::NYTProf are you using? And are you able to provide a cut-down script that can reproduce the issue?

Looking at the code, you might also be able to patch the issue by checking that $self->profile can call the inc method before it is called. You could then perhaps munge the name yourself and see what happens to the report.

Replies are listed 'Best First'.
Re^2: NYTProf line report failure
by Anonymous Monk on Mar 11, 2020 at 03:22 UTC
    I can't provide a sscce because it's a very large module. I was using 6.05 but upgraded to 6.06 after your inquiry. It still fails with the same errors except one minor difference I don't understand (2695 -> 2698):
    collapse_sibling_evals: nested evals in (eval 2695)
    collapse_sibling_evals: nested evals in (eval 2698)
    
    Debugging nytprof is over my head but I can see from the comments around line 430 in /Devel/NYTProf/FileInfo.pm that someone anticipated problems. How would you patch this?
    # Should return the filename that the application used when loading th +e file # For evals should remove the @INC portion from within the "(eval N)[$ +path]" # and similarly for Class::MOP #line evals "... defined at $path". # This is a bit of a fudge. Filename handling should be improved in th +e profiler. sub filename_without_inc { my $self = shift; my $f = [$self->filename]; strip_prefix_from_paths([$self->profile->inc], $f, # line 430 qr/(?: ^ | \[ | \sdefined\sat\s )/x ); return $f->[0]; }

      The first thing I would try is to avoid the inc call, which is what bliako does in 11114118.

      It is probably worth instrumenting the code block with print statements to see what happens in this code under normal circumstances for a simplified script with nested evals. Or you could use the debugger if you are familiar with it or have access to one through an IDE.

      (Edit 20201303 - use code, not para, tags for "inc".)

Re^2: NYTProf line report failure
by Anonymous Monk on Mar 11, 2020 at 07:45 UTC
    What does the error mean? What is undefined? Is my code causing the issue or is something wrong with NYTProf?

      One thing is sure, $self->profile returns undef. Just a wild guess: strip_prefix_from_paths() removes the ABC::XYZ from ABC::XYZ::myscript from the filename string. Or something to that effect, the ABC::XYZ is taken from your @INC I guess. I also guess that it's likely the eval refers to eval'ing some require'd modules. You could change the code like: [defined($self->profile) ? $self->profile->inc : () ], that is, give it an empty @INC if profile is undefined.

      However, something must be seriously wrong in your usage and right now you are the only one who can fix that, the rest of us we are just guessing wildly. So, reduce this problem to a minimum. Also, show the versions of all modules involved.

        This is just a wild guess, but perhaps substitute some arbitrary path name when inc is undefined? This might give it something to work with instead of an empty array. Or patch the code later to handle an empty array from that call.

        [defined($self->profile) ? $self->profile->inc : ('.') ]

        That might send you down the rabbit hole, though, in which case bliako's advice in 11114191 should be followed.

        When doing that, it is probably worth looking for what code is triggering the issue. Maybe it is the nested evals that were being warned about in the output in a previous post, but a quick check with the code below works without problem so if it is nested evals then it is under more complex conditions.

        use strict; use warnings; my $code1 = 'print "nested eval run here\n"'; my $code2 = 'eval $code1'; my $code3 = 'eval $code2'; eval $code3;
        Thank you for the suggested patch. The change to line 430 of Devel::NYTProf::FileInfo has restored functionality to nytprofhtml with some warnings about uninitialized values. I treasure your wild guesses.

        What is $self->profile and what could cause it to be undef? Is it the result of profiling a statement, or a subroutine? What do you think my usage of is seriously wrong, Perl or NYTProf? I have no problem with the module that's being profiled, or scripts that use it, or with commandline usage. I'm not doing anything unusual with NYTProf either.

        Here are those warnings:

        Writing line reports to nytprof directory 97% ... Use of uninitialized value in numeric gt (>) at /Devel/NYTPr +of/Reader.pm line 184. Use of uninitialized value in numeric gt (>) at /Devel/NYTProf/Reader. +pm line 185. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 235. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 237. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 238. Use of uninitialized value in concatenation (.) or string at /Devel/NY +TProf/Reader.pm line 188. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 540. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 541. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 542. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 543. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 544. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 545. Use of uninitialized value in sprintf at /bin/nytprofhtml line 202. 98% ... Use of uninitialized value in numeric gt (>) at /Devel/NYTPr +of/Reader.pm line 184. Use of uninitialized value in numeric gt (>) at /Devel/NYTProf/Reader. +pm line 185. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 235. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 237. Use of uninitialized value $fname in substitution (s///) at /Devel/NYT +Prof/Util.pm line 238. Use of uninitialized value in concatenation (.) or string at /Devel/NY +TProf/Reader.pm line 188. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 540. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 541. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 542. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 543. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 544. Use of uninitialized value $_ in substitution (s///) at /bin/nytprofht +ml line 545. Use of uninitialized value in sprintf at /bin/nytprofhtml line 202. 100% ... Extracting subroutine call data (There were 9159849 of them, so this m +ay take some time, or cancel and use --no-flame to skip this step.) . +.. Extracting subroutine links Generating subroutine stack flame graph ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114102]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found