dtrace-utils icon indicating copy to clipboard operation
dtrace-utils copied to clipboard

TLS struct variables should be allocated only for nonzero values

Open euloh opened this issue 3 years ago • 0 comments

For thread-local variables and associative arrays, the documentation says that unassigned variables are considered to be initialized to zero. Storage is not allocated until nonzero values are assigned. Storage is to be freed when zero values are assigned.

These semantics are not well handled for struct variables. Consider

    struct foo {
        int bar, baz;
    } x;

We cannot assign zero to x to free its storage since x=0 is not defined. And we cannot initialize a member x.bar=1 unless x already exists.

These issues are not new to the port of DTrace onto BPF. They existed already in the legacy DTrace implementation on Linux.

euloh avatar Dec 03 '21 00:12 euloh