`CON34-C`: Implementation seems to check incorrect aspects of thread storage duration objects
MichaelRFairhurst opened this issue · 1 comments
MichaelRFairhurst commented
Affected rules
CON34-C
Description
The documentation seems to describe the risk of passing a tss_t into a thread. The risk here is that the new thread will have no value.
In the "compliant" case it says the appropriate fix is to use tss_get() to get the value in the current thread, then pass that value into the new thread.
In our implementation, we check that any tss_t values are definitely given a value before retrieved and passed into a thread creation statement. This is not the intention of the rule, adds additional implementation complexity, and reveals no violations in MRVA.
Example
tss_t key;
void f1() {
// Should be marked non-compliant: new thread has no value for tss_get(key)
// Currently not reported
thrd_create(..., &key);
}
void f2() {
// While the following code is suspect, it is NOT the intention of the rule is not to disallow this:
tss_t localkey;
tss_set(localkey, malloc(...));
void* v = tss_get(localkey);
thrd_create(..., v);
// The fact that v is uninitialized has nothing to do with threads. For instance, this is also erroneous:
printf("%d", *v);
// Further, the above code has nothing to do with thread storage duration, and isn't necessarily invalid:
static void *shared_buf = malloc(...);
thrd_create(..., shared_buf); // Reasonable pattern
}MichaelRFairhurst commented
Seems like this was closed erroneuosly