[BUG] event_wait_timed can't return false

Aperta
#1,546 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@TedLyngmo ci sta già lavorando.

Dal 23/10/2026.

  • #1525 di @TedLyngmo — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Start in portable/ThirdParty/GCC/Posix/utils/wait_for_event.c, in event_wait_timed, and check what the return value of pthread_cond_timedwait is compared against on the timeout path; the reported symptom is that every reachable branch returns true. Build the reproducer from the issue against that file (gcc -D_GNU_SOURCE ... -pthread) and confirm the first assert fails, then confirm the mutex is released on timeout. Note that an open pull request, #1525, already targets this, so read it before writing anything.

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

Descrizione

bug

Describe the bug
event_wait_timed returns true in all reachable branches.

Target
All targets using the portable/ThirdParty/GCC/Posix/utils/wait_for_event.c version of event_wait_timed.

Host

  • Host OS: Fedora
  • Version: 44

To Reproduce
Compile and run this on a Posix target. It will fail:

/* gcc -D_GNU_SOURCE t.c wait_for_event.c -pthread && ./a.out */
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "wait_for_event.h"

static void * sig( void * ev )
{
    usleep( 50000 );
    event_signal( ev );
    return NULL;
}

int main( void )
{
    struct event * ev = event_create();
    pthread_t th;

    /* Timeout must report false, and must not leak the mutex. */
    assert( event_wait_timed( ev, 100 ) == false );

    /* Object still usable after timeout; signal must report true. */
    pthread_create( &th, NULL, sig, ev );
    assert( event_wait_timed( ev, 5000 ) == true );
    pthread_join( th, NULL );

    event_delete( ev );
    puts( "OK" );
}

Expected behavior
I'm expecting a false return in the first assert signalling a timeout but, even though it times out, the function returns true.

Lingua principale
C
Stelle
4.6k
Fork
1.6k
Merge medio
2g 22h
PR unite (30g)
4

Preparare l'ambiente

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 FreeRTOS/FreeRTOS-Kernel

Tutte le issue di FreeRTOS/FreeRTOS-Kernel

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.