`CON34-C`: Implementation seems to check incorrect aspects of thread storage duration objects
関連するプルリクエストがすでにマージされています。
- #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時間
- マージ済み PR(30日)
- 9
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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