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

Avoid potential race between read and upload_data #231

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

Conversation

gbaraldi
Copy link
Member

upload_data might set easy.input to nothing before it's actually read if read_callbacks runs before it.

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #231 (7531f74) into master (246504e) will decrease coverage by 0.34%.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #231      +/-   ##
==========================================
- Coverage   90.26%   89.93%   -0.34%     
==========================================
  Files           5        5              
  Lines         575      576       +1     
==========================================
- Hits          519      518       -1     
- Misses         56       58       +2     
Files Changed Coverage Δ
src/Curl/Easy.jl 91.58% <100.00%> (-0.65%) ⬇️

... and 3 files with indirect coverage changes

@vtjnash
Copy link
Member

vtjnash commented Aug 31, 2023

Do you have an example? That sounds like a much more severe data race than this change would fix, but I don't see how you could encounter that situation, since read_callbacks should only occur after this method calls CURLPAUSE_CONT.

@gbaraldi
Copy link
Member Author

gbaraldi commented Aug 31, 2023

So I've hit this in the IO thread PR by just doing

using Downloads

url = "https://httpbingo.julialang.org/put"
file = tempname()
write(file, "Hello, world!")
resp = nothing
body = sprint() do output
    resp = request(url; output=output, input=file)
end

I'm still grasping my way around this codebase, but I don't see a way that read_callbacks is forced to run after upload_data has run. It might also be a bug on the IO thread PR, but the other issues i've seen so far are those that use the running of the IO Loop as an implicit synchronization step.

@StefanKarpinski
Copy link
Member

@gbaraldi, what do you think of @vtjnash's latest version of this? Does it fix the issue for you? I'm happy to merge (and backport) whatever version this you guys settle on.

@vchuravy
Copy link
Member

vchuravy commented Sep 6, 2023

We discussed this during the multi-threading WG call. I just tested locally and it looks good.
Deployed this to JuliaLang/julia#50880 and we will see what Base CI says.

@vchuravy
Copy link
Member

vchuravy commented Sep 6, 2023

@StefanKarpinski this looks good on Base CI.
This does require Julia 1.8 though, how do you want to handle that?

@StefanKarpinski
Copy link
Member

I guess we don't backport to 1.6 then. This becomes a fix only for newer versions.

@vchuravy
Copy link
Member

vchuravy commented Sep 7, 2023

So should I just remove the CI for 1.3? Or do you want a VERSION >= v"1.8.0" check?

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.

4 participants