[dtrace-discuss] "this" variables being overridden?

Yossi Lev (Sun Labs)
2009-09-17T22:56:05Z

Hi

I encountered this problem a few times in the past, but only now it is
consistent enough so I can write this email.  In short, the problem is
that after I copy some structure from the profiled program to the dtrace
space, and set a "this-dataP" variable to point to the local copy,
after
a while some of the fields of the local structure are overridden with
junk values.  In particular, consider the following code:

pid$target::foo:entry
{
  this->dataP = (ProfData*)copyin(arg2, sizeof(ProfData));
}


/* various of other foo:entry clauses with various predicates.
 * None of them is doing a copyin operation.
 */

[snip]

pid$target::foo:entry
/disabled[0]==0 && arg1 != 0/
{

  this->ablock = arg0;

  this->time = this->dataP->execTime;
  this->ltime = this->dataP->logTxExecTime;
  this->wtime = this->dataP->confWaitTime;
  this->trials = this->dataP->counters[NumRetries];

  this->confsWonWR   = this->dataP->counters[NumWonWRConf] ? 1:0;
  this->confsWonWRUp = this->dataP->counters[NumWonWRUpConf] ? 1:0;
  this->confsWonRW   = this->dataP->counters[NumWonRWConf] ? 1:0;
  this->confsWonWW   = this->dataP->counters[NumWonWWConf] ? 1:0;

  @txInfo[
    this->ablock,
    this->trials,
    this->time/1000,
    this->ltime/1000,
    this->wtime/1000,
    this->confsWonWR,
    this->confsWonWRUp,
    this->confsWonRW,
    this->confsWonWW] = count();
}


At the end of the run, I noticed that some of the data points in the
aggregation have junk values in some of their key fields.
If I add another:

  this->dataP = (ProfData*)copyin(arg2, sizeof(ProfData));

in the clause where the aggregation is assigned, then the number of junk
values is significantly reduced, but does not completely disappear...
(My understanding is that adding this additional copyin is not
necessary, as "this" variables should be live until the last code
block
that corresponds to a particular probe firing is done executing.)

Any ideas what is going on?  As said, I noticed this phenomena in a
number of different scripts --- in all it seems like the more time it
passes between the copyin and the usage of the data, the more likely
I''ll see junk values...

Yossi