Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to cancel NULL thread (causing Segmentation fault) #1801

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidBar-On
Copy link
Contributor

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies:

  • Issues fixed (if any): none

  • Brief description of code changes (suitable for use as a commit message):

Suggested Bug fix: thread id 0 is not regarded as illegal id (at least in Ubuntu Linux), and pthread_cancel() crashes (Segmentation fault) when trying to cancel a thread with id 0. That happens if streams creation was successful, but there was a failure before all threads are created. The problem happened to me at work and I can reproduce it in my private PC.

The suggested fix is to add an indication thread_created per stream to indicate if the thread was created for the stream, and try to cancel the stream's thread only if it was created.

Copy link
Contributor

@bmah888 bmah888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This looks like a good change (set of changes). Just one comment, mostly FYI and not something that needs to be "fixed". Just need to do some testing on this...

src/iperf_api.c Outdated
@@ -4498,6 +4498,7 @@ iperf_new_stream(struct iperf_test *test, int s, int sender)

memset(sp, 0, sizeof(struct iperf_stream));

sp->thread_created = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically don't need this line because of the memset() above. It's not wrong to have it here though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line removed.

@bmah888 bmah888 self-assigned this Nov 22, 2024
@bmah888 bmah888 added the bug label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants