Skip to content

Commit

Permalink
Ensure that 'execname' is not marked DPTR
Browse files Browse the repository at this point in the history
The 'execname' builtin variable is a notable exception to REF-type
variables being DTrace-managed pointers.  It is a pointer into the
task_struct and therefore needs to be explicitly excluded from the
DPTR marking of variable nodes.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Oct 27, 2022
1 parent 182688e commit 0236a08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libdtrace/dt_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2837,9 +2837,13 @@ dt_xcook_ident(dt_node_t *dnp, dt_idhash_t *dhp, uint_t idkind, int create)
* storage (DPTR), or if the type of the variable is a
* REF-type, we mark this variable node as a pointer to
* DTrace-managed storage (DPTR).
*
* We account for one notable exception: execname.
*/
if ((idp->di_flags & DT_IDFLG_DPTR) ||
(dnp->dn_flags & DT_NF_REF))
if (idp->di_flags & DT_IDFLG_DPTR)
dnp->dn_flags |= DT_NF_DPTR;
else if ((dnp->dn_flags & DT_NF_REF) &&
idp->di_id != DIF_VAR_EXECNAME)
dnp->dn_flags |= DT_NF_DPTR;

if (idp->di_flags & DT_IDFLG_WRITE)
Expand Down
19 changes: 19 additions & 0 deletions test/unittest/codegen/tst.execname-idx.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/

#pragma D option quiet

BEGIN
{
trace(execname[0]);
exit(0);
}

ERROR
{
exit(1);
}

0 comments on commit 0236a08

Please sign in to comment.