Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

NYTProf line report failure

by Anonymous Monk
on Mar 09, 2020 at 22:03 UTC ( [id://11114050]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've been using nytprof for years and never saw it fail. The "perl -d:NYTProf script" part works but the HTML generator "nytprofhtml" fails with these errors (with cleaned up paths):
Reading nytprof.out Processing nytprof.out data collapse_sibling_evals: nested evals in (eval 656)[/ExtUtils/MM_Unix.p +m:2920] not handled at /Devel/NYTProf/FileInfo.pm line 291. collapse_sibling_evals: nested evals in (eval 2695)[/Module/Metadata.p +m:13] not handled at /Devel/NYTProf/FileInfo.pm line 291. Writing line reports to nytprof directory 97% ... Can't call method "inc" on an undefined value at /Devel/NYTProf/FileInfo.pm line 430.
Not sure what to do next. Thank you

Code tags added by GrandFather

Replies are listed 'Best First'.
Re: NYTProf line report failure
by swl (Parson) on Mar 10, 2020 at 21:36 UTC

    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.

      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".)

      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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found