[DTrace-devel] [PATCH] Avoid checkng for NULL pointers multiple times

Kris Van Hees kris.van.hees at oracle.com
Mon Dec 13 18:57:34 UTC 2021


On Mon, Dec 13, 2021 at 01:52:25PM -0500, Eugene Loh via DTrace-devel wrote:
> s/checkng/checking/ in the subject line.
> 
> On 12/13/21 12:51 AM, Kris Van Hees via DTrace-devel wrote:
> > The dt_cg_load_var() function was also creting two labels that were
> > only actually used in one branch.  In addition, Eugene Loh pointed
> > out that a MOV instruction could be saved as well.
> s/creting/creating/
> 
> And perhaps "In addition" or else "as well" but maybe not both.
> > diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> > @@ -2569,8 +2566,14 @@ dt_cg_arithmetic_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
> >   		dt_cg_ptrsize(dnp, dlp, drp, BPF_MUL, dnp->dn_left->dn_reg);
> >   	dt_cg_node(dnp->dn_right, dlp, drp);
> > -	if (is_ptr_op && lp_is_ptr)
> > -		dt_cg_ptrsize(dnp, dlp, drp, BPF_MUL, dnp->dn_right->dn_reg);
> > +	if (is_ptr_op) {
> > +		if (lp_is_ptr) {
> > +			dt_cg_ptrsize(dnp, dlp, drp, BPF_MUL,
> > +				      dnp->dn_right->dn_reg);
> > +			dt_cg_check_notnull(dlp, drp, dnp->dn_left->dn_reg);
> > +		} else
> > +			dt_cg_check_notnull(dlp, drp, dnp->dn_right->dn_reg);
> > +	}
> >   	if ((op == BPF_MOD || op == BPF_DIV) &&
> >   	    (dnp->dn_flags & DT_NF_SIGNED)) {
> # dtrace -n 'BEGIN { x = y = 0; trace(x+y); exit(0) }'
> dtrace: description 'BEGIN ' matched 1 probe
> dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address
> (0x0) in action #1
> 
> ???
> 
> I think the problem is that we have is_ptr_op.  So we could have lp_is_ptr
> or rp_is_ptr but not both.  But we could have neither!
> 
> Maybe you need to turn the "else" into "else if (rp_is_ptr)"?

Yes, I was too hasty in sending that patch.  I missed a few cases.  Working on
v2.



More information about the DTrace-devel mailing list