All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Kris Van Hees <kris.van.hees@oracle.com>
Cc: Alan Maguire <alan.maguire@oracle.com>,
	dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [DTrace-devel] [PATCH v7 2/7] support stapsdt ELF-note-defined static probes
Date: Tue, 5 Aug 2025 15:05:28 -0400	[thread overview]
Message-ID: <aJJV+HZNnqOprcOK@oracle.com> (raw)
In-Reply-To: <aJJSUEWU0eLuHKEd@oracle.com>

On Tue, Aug 05, 2025 at 02:49:52PM -0400, Kris Van Hees wrote:
> Comments below.

I wrote too hastily... see below...
> 
> On Wed, Jul 30, 2025 at 10:01:43AM +0100, Alan Maguire via DTrace-devel wrote:
<< skip >>
> > +static int
> > +dt_pid_create_stapsdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
> > +{
> > +	const dt_provider_t *pvp;
> > +	dt_proc_t *dpr = NULL;
> > +	const char *pidstr;
> > +	char *path = NULL;
> > +	pid_t pid;
> > +
> > +	assert(pcb != NULL);
> > +
> > +	pidstr = &pdp->prv[strlen(pdp->prv)];
> > +
> > +	while (isdigit(*(pidstr - 1)))
> > +		pidstr--;
> > +	if (strlen(pidstr) == 0)
> > +		return 0;
> > +
> > +	asprintf(&path, "/proc/%s/maps", pidstr);
> 
> If this fails, asprintf() returns -1, and path is undefined.  So there should
> be a check to deal with that.

Actually, since path is only used in the code block near the end of the funtion
there is no point initializing path here, because that creates multiple places
where you would need to free it.  Just move the declaration of path and the
asprintf into the code block.
> 
> > +
> > +	pvp = dt_provider_lookup(dtp, "stapsdt");
> > +	assert(pvp != NULL);
> > +
> > +	pid = atoll(pidstr);
> > +	if (pid <= 0)
> > +		return 0;
> > +	if (dt_proc_grab_lock(dtp, pid, DTRACE_PROC_WAITING |
> > +			      DTRACE_PROC_SHORTLIVED) < 0) {
> > +		dt_pid_error(dtp, pcb, NULL, D_PROC_GRAB,
> > +			     "failed to grab process %d",
> > +			     (int)pid);
> > +		return 1;
> > +	}
> > +	dpr = dt_proc_lookup(dtp, pid);
> > +	if (dpr) {

char *path = NULL;

if (asprintf(...) == -1)
  longjmp(pcb->pcb_jumpbuf, EDT_NOMEM);

> > +		dt_pid_create_stapsdt_probes_proc(pdp, dtp, pcb,
> > +						  pvp, dpr, path);

free(path)

> > +		dt_proc_release_unlock(dtp, pid);
> > +	}
> > +
> > +	return 0;
> > +}

  reply	other threads:[~2025-08-05 19:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  9:01 [PATCH v7 0/7] add support for stapsdt probes Alan Maguire
2025-07-30  9:01 ` [PATCH v7 1/7] usdt: have copy_args() count args while parsing them Alan Maguire
2025-08-05 15:04   ` Kris Van Hees
2025-07-30  9:01 ` [PATCH v7 2/7] support stapsdt ELF-note-defined static probes Alan Maguire
2025-08-05 18:49   ` [DTrace-devel] " Kris Van Hees
2025-08-05 19:05     ` Kris Van Hees [this message]
2025-07-30  9:01 ` [PATCH v7 3/7] selftests/usdt: add test for stapsdt note-defined probe firing, args Alan Maguire
2025-07-30  9:01 ` [PATCH v7 4/7] selftests/usdt: add test for stapsdt notes in shared library Alan Maguire
2025-07-30  9:01 ` [PATCH v7 5/7] selftests/usdt: add test covering different forms of stapsdt note args Alan Maguire
2025-07-30  9:01 ` [PATCH v7 6/7] selftests/usdt: add test for stapsdt note-defined probe firing in -fPIE binary Alan Maguire
2025-07-30  9:01 ` [PATCH v7 7/7] selftests/usdt: add is-enabled stapsdt tests using semaphores Alan Maguire

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=aJJV+HZNnqOprcOK@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.