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

common: Add thread safety on libcurl usage #5046

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

mcrha
Copy link
Contributor

@mcrha mcrha commented Aug 16, 2022

There can happen a race condition between internal libcurl structure
content when two threads set the data structure for the callbacks
from two threads, which can cause access of already freed stack-allocated
data, resulting in a memory corruption.

Closes #3701


An alternative solution, which can run requests in parallel, would be to create a new FlatpakHttpSession for every request. It seems to be a cheap structure, both for libcurl and for libsoup, but I'm not that used to those structures, thus I cannot tell for sure. I can change the commit to do that instead, if needed.

There can happen a race condition between internal libcurl structure
content when two threads set the `data` structure for the callbacks
from two threads, which can cause access of already freed stack-allocated
`data`, resulting in a memory corruption.

Closes flatpak#3701
@mcrha mcrha force-pushed the wip/thread-safety-with-libcurl branch from 99e396c to 0030d49 Compare August 17, 2022 09:26
@alexlarsson alexlarsson merged commit dc82a19 into flatpak:main Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential threading issue
5 participants