zsh-workers
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] zprof: Don't tally all anonymous functions as though they were a single function named "(anon)".
Date: Tue, 26 May 2020 22:15:46 +0000	[thread overview]
Message-ID: <f3a50c33-970f-4d47-a6f6-c7f8e97fc4ea@www.fastmail.com> (raw)
In-Reply-To: <20200526220638.26711-1-danielsh@tarpaulin.shahaf.local2>

Daniel Shahaf wrote on Tue, 26 May 2020 22:06 +00:00:
> +++ b/Src/Modules/zprof.c
> @@ -213,7 +213,25 @@ bin_zprof(UNUSED(char *nam), UNUSED(char **args), 
> @@ -224,12 +242,19 @@ zprof_wrapper(Eprog prog, FuncWrap w, char *name)
> +    char *name_for_lookups;
> +
> +    if (is_anonymous_function_name(name)) {
> +        name_for_lookups = name_for_anonymous_function(name);
> +    } else {
> +        name_for_lookups = ztrdup(name);

Memory leak when either of the next two conditions is false.

> +    }
>  
>      if (zprof_module && !(zprof_module->node.flags & MOD_UNLOAD)) {
>          active = 1;
> -        if (!(f = findpfunc(name))) {
> +        if (!(f = findpfunc(name_for_lookups))) {
>              f = (Pfunc) zalloc(sizeof(*f));
> -            f->name = ztrdup(name);
> +            f->name = name_for_lookups;
>              f->calls = 0;
>              f->time = f->self = 0.0;
>              f->next = calls;

> Should «funcstack» be checked for NULL before it's dereferenced?  
> The funcstack frame is added in doshfunc() while wrappers are called
> from runshfunc().  I don't see any case in which doshfunc() won't have
> been called by the time runshfunc() has, but then I don't completely
> grok the sense of the EF_RUN flag as used in doshfunc().

This question stands.

Cheers,

Daniel

      reply	other threads:[~2020-05-26 22:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 22:06 Daniel Shahaf
2020-05-26 22:15 ` Daniel Shahaf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3a50c33-970f-4d47-a6f6-c7f8e97fc4ea@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).