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

Moving *this before calling get_immediate_executor() causes undefined behavior #2925

Closed
Jackarain opened this issue Sep 4, 2024 · 3 comments · Fixed by #2926
Closed

Moving *this before calling get_immediate_executor() causes undefined behavior #2925

Jackarain opened this issue Sep 4, 2024 · 3 comments · Fixed by #2926
Labels

Comments

@Jackarain
Copy link

In the following code, std::move(*this) is used before calling get_immediate_executor(). This can result in undefined behavior, as the this object may become invalid after the move operation.

net::dispatch(this->get_immediate_executor(),
net::append(std::move(*this), ec, 0));
}

@ashtum ashtum added the Bug label Sep 4, 2024
@ashtum
Copy link
Collaborator

ashtum commented Sep 4, 2024

@Jackarain Thanks for reporting this. I can confirm that this is a bug, as the order of evaluation of function arguments is unspecified and move can happen before dereferencing this.

ashtum added a commit to ashtum/beast that referenced this issue Sep 4, 2024
@Jackarain
Copy link
Author

感谢您的回复,以及迅速的作出修复,感谢

@vinniefalco
Copy link
Member

Great work, @Jackarain :) thanks.

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 a pull request may close this issue.

3 participants