oracle / dtrace-utils

DTrace-utils contains the DTrace port to Linux
Other
153 stars 20 forks source link

TLS struct variables should be allocated only for nonzero values #58

Open euloh opened 2 years ago

euloh commented 2 years ago

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.