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

Race condition possibly manifesting as missing request #431

Open
earce opened this issue Sep 22, 2023 · 0 comments
Open

Race condition possibly manifesting as missing request #431

earce opened this issue Sep 22, 2023 · 0 comments

Comments

@earce
Copy link

earce commented Sep 22, 2023

Encountered the error when running some code with busy cpu usage:

2023-09-21T21:53:32.563521901Z [WARN] (isahc-agent-0): received unpause request for unknown request token: 0

which implies that either

  1. the request was removed from the map before it should've
  2. the request received a UnpauseRead after it should've
  3. there is a race condition where the lookup occurs before it is available in the map

Looking more closely at this function https://github.com/sagebind/isahc/blob/master/src/agent/mod.rs#L332

it appears like UnpauseRead gets written to a concurrent queue followed by the inner waker having wake_by_ref called on it. It seems like while we are only running a single agent thread which handles both the reading off this queue and writing (barring the outside threads which can write to this queue via send_message).

Reading the wake_by_ref doc it seems like it can cause the current thread to yield and enter the poll cycle? is it possible that this logic gets run again but since requests.insert doesn't happen until like 366 there is a race where that request isn't in there yet?

Should this insertion happen at the top of this function?

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

No branches or pull requests

1 participant