dtrace-utils
dtrace-utils copied to clipboard
Need better diagnostics for when dynvarsize < dt_maxtlslen
We allocate space for dynamics variables, such as TLS variables, statically. Users have control over the space with the DTrace option dynvarsize. The size should be picked based on the largest variable size. Statically, we track the largest TLS variable size with dt_maxtlslen.
The size also depends on how many variables must be stored concurrently, however, and this cannot be known statically. Therefore, it is possible that there is insufficient storage and variables must be "dropped" at run time.
Nevertheless, we can provide more helpful diagnostics in at least one case: when dynvarsize < dt_maxtlslen. That is, static analysis tells us that there are TLS variables and yet we will allocate space for none of them.
Consider, for example:
# cat z.d
struct foo {
long long a1, a2, a3, a4, a5, a6, a7, a8, a9;
};
self struct foo x;
BEGIN {
self->a = 1;
exit(0);
}
# dtrace -xdynvarsize=32 -s z.d
dtrace: script 'z.d' matched 1 probe
EUGENE 32 / 72 = 1
dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address (0x0) in action #1
Though the large struct is never used, there is insufficient storage even for a 4-byte int.
One can argue about how likely such scenarios are. The main point, however, is that we can easily generate helpful diagnostics for the case that dynvarsize < dt_maxtlslen.