[BUG] event_wait_timed can't return false

Đang mở
#1,546 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@TedLyngmo đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #1525 của @TedLyngmo — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
operating-systems

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C
Star
4.6k
Fork
1.6k
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của FreeRTOS/FreeRTOS-Kernel

Tất cả issue của FreeRTOS/FreeRTOS-Kernel

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.