anchao commented on issue #17418: URL: https://github.com/apache/nuttx/issues/17418#issuecomment-3661099752
> [@anchao](https://github.com/anchao) Please see this reproduce testcase. If you don't have any questions about the issue, we will revert the following PR: [#11832](https://github.com/apache/nuttx/pull/11832) @GUIDINGLI Hi again, work fine after apply : https://github.com/apache/nuttx/compare/master...wangzhi16:nuttx:master https://github.com/apache/nuttx-apps/compare/master...wangzhi16:nuttx-apps:dev ``` archer@archerc:~/code/nuttx/n4/nuttx$ ./nuttx NuttShell (NSH) NuttX-10.4.0 nsh> hello Test PASSED nsh> ``` could we reproduce this issue on upstream? patch diff: ``` archer@archerc:~/code/nuttx/n4/apps$ git diff . diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c index fd194a623..1f368861e 100644 --- a/examples/hello/hello_main.c +++ b/examples/hello/hello_main.c @@ -26,6 +26,36 @@ #include <nuttx/config.h> #include <stdio.h> +#include <sys/wait.h> + +#define TIMEOUT 5 /* Timeout value of 5 seconds. */ +#define INTHREAD 0 /* Control going to or is already for Thread */ +#define INMAIN 1 /* Control going to or is already for Main */ + +#define PTS_PASS 0 +#define PTS_FAIL 1 +#define PTS_UNRESOLVED 2 +#define PTS_UNSUPPORTED 4 +#define PTS_UNTESTED 5 + +static int sem1; /* Manual semaphore */ + +static void *a_thread_func(void *arg) +{ + + /* Indicate to main() that the thread was created. */ + sem1 = INTHREAD; + + /* Wait for main to detach change the attribute object and try and detach this thread. + * Wait for a timeout value of 10 seconds before timing out if the thread was not able + * to be detached. */ + sleep(TIMEOUT); + + printf + ("Test FAILED: Did not detach the thread, main still waiting for it to end execution.\n"); + pthread_exit((void *)PTS_FAIL); + return NULL; +} /**************************************************************************** * Public Functions @@ -37,6 +67,44 @@ int main(int argc, FAR char *argv[]) { - printf("Hello, World!!\n"); - return 0; + pthread_t new_th; + pthread_attr_t new_attr; + int ret_val; + + /* Initializing */ + sem1 = INMAIN; + if (pthread_attr_init(&new_attr) != 0) { + perror("Cannot initialize attribute object\n"); + return PTS_UNRESOLVED; + } + + /* Create a new thread passing it the new attribute object */ + if (pthread_create(&new_th, &new_attr, a_thread_func, NULL) != 0) { + perror("Error creating thread\n"); + return PTS_UNRESOLVED; + } + + /* Wait for thread to indicate that the start routine for the thread has started. */ + while (sem1 == INMAIN) + sleep(1); + + /* If pthread_detach fails, that means that the test fails as well. */ + ret_val = pthread_detach(new_th); + + if (ret_val != 0) { + /* Thread is already detached. */ + if (ret_val == EINVAL) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + /* pthread_detach() failed for another reason. */ + else { + printf("Error in pthread_detach(), error: %d\n", + ret_val); + return PTS_UNRESOLVED; + } + } + + printf("Test PASSED\n"); + return PTS_PASS; } ``` ``` archer@archerc:~/code/nuttx/n4/nuttx$ git diff . diff --git a/sched/signal/sig_cleanup.c b/sched/signal/sig_cleanup.c index 9bb8d9a733..3eef7bb94c 100644 --- a/sched/signal/sig_cleanup.c +++ b/sched/signal/sig_cleanup.c @@ -61,6 +61,10 @@ void nxsig_cleanup(FAR struct tcb_s *stcb) nxsig_release_pendingsigaction(sigq); } + /* Using sleep to simulate the blocking that free might encounter. */ + + usleep(1); + /* Misc. signal-related clean-up */ sigfillset(&stcb->sigprocmask); ``` -- 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]
