Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

`CON34-C`: Implementation seems to check incorrect aspects of thread storage duration objects

Offen
#801 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #778 von @lcartey — gemerged

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
c
Bereich
tooling

Rechercherichtung

Beginne mit der CON34-C-Implementierung und ihrer vorhandenen Validierung für tss_t-Werte und vergleiche sie anschließend mit den konformen und nicht konformen Beispielen in diesem Issue. Die Änderung ist abgeschlossen, wenn der beabsichtigte Thread-Storage-Verstoß gemeldet wird und nicht verwandte Fälle mit nicht initialisierten Werten nicht CON34-C zugeschrieben werden; validiere dies mit den für die Regel verfügbaren Tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

false positive/false negative Standard-CERT-C
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
}
Vorherrschende Sprache
CodeQL
Sterne
227
Forks
82
Ø Merge
6 T. 7 Std.
Gemergte PRs (30 T.)
9

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus github/codeql-coding-standards

Alle Issues in github/codeql-coding-standards

Ähnliche Issues

Weitere Issues zu DevTools

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.