RT-Thread / RT-Thread/rt-thread
[Bug] pthread_cancel线程无法退出
Open
Nobody has claimed this yet.
Arch: RISC-V
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
Description
RT-Thread Version
c9c103f30e28b31e5d393e7a8cc1a07779fb99dc
Hardware Type/Architectures
risc-v c908
Develop Toolchain
GCC
Describe the bug
调用pthread_cancel线程无法退出,附上测试代码
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
pthread_t tid;
static void *subthread(void *arg)
{
while (1) {
usleep(1000000);
printf("%s: %d\n", __func__, __LINE__);
}
return 0;
}
int main(int argc, char **argv)
{
pthread_create(&tid, NULL, subthread, 0);
while (getchar() != 'q')
usleep(10000);
printf("%s: %d\n", __func__, __LINE__);
pthread_cancel(tid);
printf("%s: %d\n", __func__, __LINE__);
pthread_join(tid, NULL);
printf("%s: %d\n", __func__, __LINE__);
return 0;
}
Other additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report on the stated RISC-V C908 target with GCC using the provided pthread_create, pthread_cancel, and pthread_join program. Start by locating the implementations of pthread_cancel and pthread_join, then trace how cancellation interacts with the thread blocked in usleep. Done means the cancelled thread exits and pthread_join completes as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100