Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#801 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Una pull request collegata è già stata integrata.

  • #778 di @lcartey — integrata

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c
Ambito
tooling

Direzione di ricerca

Inizia con l’implementazione di CON34-C e la relativa validazione esistente per i valori tss_t, quindi confrontala con gli esempi conformi e non conformi presenti in questa issue. La modifica è completata quando viene segnalata la violazione prevista del thread storage e i casi non correlati di valori non inizializzati non vengono attribuiti a CON34-C; convalida il risultato con i test disponibili per la regola.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
}
Lingua principale
CodeQL
Stelle
227
Fork
82
Merge medio
6g 7h
PR unite (30g)
9

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/codeql-coding-standards

Tutte le issue di github/codeql-coding-standards

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.