casaroli commented on code in PR #3931: URL: https://github.com/apache/nuttx-apps/pull/3931#discussion_r4398256781
########## testing/ostest/Makefile: ########## @@ -99,6 +99,11 @@ endif ifneq ($(CONFIG_DISABLE_PTHREAD),y) CSRCS += cancel.c cond.c mutex.c timedmutex.c sem.c semtimed.c barrier.c CSRCS += timedwait.c pthread_rwlock.c pthread_rwlock_cancel.c schedlock.c +ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) +ifneq ($(CONFIG_BUILD_KERNEL),y) Review Comment: Size is not the cause. pthread_sigqueue() is in nuttx sched/pthread and has no system call (it is not in `syscall/syscall.csv`), so user code cannot link it in protected or kernel builds: CI still fails with `undefined reference to 'pthread_sigqueue'` in nuttx_user.elf of smartl-c906:knsh (BUILD_PROTECTED). The `CONFIG_BUILD_KERNEL` gate only hides the test in kernel builds. Fix: add `pthread_sigqueue` to nuttx `syscall/syscall.csv` (and remove it from `libs/libc/libc.csv`), then drop the `CONFIG_BUILD_KERNEL` gates; or gate the test on `CONFIG_BUILD_FLAT` in Makefile, CMakeLists.txt, ostest.h and ostest_main.c. ########## testing/ostest/pthread_sigqueue.c: ########## @@ -0,0 +1,273 @@ +/**************************************************************************** + * apps/testing/ostest/pthread_sigqueue.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <assert.h> +#include <errno.h> +#include <pthread.h> +#include <semaphore.h> +#include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <unistd.h> + +#include "ostest.h" + +#ifndef CONFIG_BUILD_KERNEL + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define TEST_SIGNO SIGUSR1 +#define TEST_VAL_INT 42 + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static sem_t g_ready_sem; +static sem_t g_done_sem; +static volatile bool g_sigreceived; +static volatile int g_received_signo; +static volatile int g_received_code; +static volatile int g_received_val; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sigqueue_handler + ****************************************************************************/ + +static void sigqueue_handler(int signo, FAR siginfo_t *info, + FAR void *ucontext) +{ + if (info != NULL) + { + g_received_signo = signo; + g_received_code = info->si_code; + g_received_val = info->si_value.sival_int; + g_sigreceived = true; + } + + sem_post(&g_done_sem); +} + +/**************************************************************************** + * Name: sigqueue_thread + ****************************************************************************/ + +static FAR void *sigqueue_thread(FAR void *arg) +{ + struct sigaction act; + sigset_t set; + int status; + + /* Setup signal action */ + + act.sa_sigaction = sigqueue_handler; + act.sa_flags = SA_SIGINFO; + sigemptyset(&act.sa_mask); + + status = sigaction(TEST_SIGNO, &act, NULL); Review Comment: sigaction() is process-wide and the test never restores it. Later, mqueue_test() sends SIGUSR1 to its receiver (mqueue.c:386), which then runs sigqueue_handler() and posts the destroyed g_done_sem. Fix: save the old action with `sigaction(TEST_SIGNO, &act, &oact)` and restore it after pthread_join(), as sighand.c does at line 202. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
