`CON34-C`: Implementation seems to check incorrect aspects of thread storage duration objects
已经有一个关联 PR 被合并了。
- #778 来自 @lcartey —— 已合并
评估
调研方向
从 CON34-C 的实现及其针对 tss_t 值的现有验证开始,然后将其与此 issue 中的符合要求和不符合要求的示例进行比较。当预期的 thread-storage 违规被报告,且无关的未初始化值案例不被归因于 CON34-C 时,修改即完成;使用该规则可用的测试进行验证。
由索引模型根据 Issue 内容生成。
描述
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
}
- 主要语言
- CodeQL
- 星标
- 227
- 派生
- 82
- 平均合并
- 6 天 7 小时
- 30 天内合并 PR
- 9
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/codeql-coding-standards 的其他 Issue
-
false positive/false negative Stardard-MISRA-C++
难度 2/5 1-3 小时 新手友好度 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
难度 2/5 1-3 小时 新手友好度 68/100
-
Difficulty-Medium false positive/false negative false-positive Impact-Medium Standard-CERT-C
难度 4/5 3-5 天 新手友好度 48/100
github/codeql-coding-standards#1200 ·
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph 未关闭false positive/false negative
难度 4/5 3-5 天 新手友好度 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative
难度 3/5 1-2 天 新手友好度 65/100
github/codeql-coding-standards#1175 ·
查看 github/codeql-coding-standards 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 1/5 1-3 小时 新手友好度 86/100
DavidAnson/markdownlint-cli2#940 ·
-
难度 1/5 1 小时以内 新手友好度 72/100
EclipseFdn/open-vsx.org#13385 · 1 条评论 ·
-
bug ci good first issue
难度 2/5 1-3 小时 新手友好度 88/100