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

Data race when consuming input RawBody #467

Open
jonandernovella opened this issue Jun 5, 2024 · 1 comment
Open

Data race when consuming input RawBody #467

jonandernovella opened this issue Jun 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jonandernovella
Copy link

I think we have spotted a data race when consuming the raw body of the input across multiple go routines.

Here a minimal environment where we manage to reproduce this: https://github.com/jonandernovella/huma-par-body/tree/main

One may detect the data race running: go test -v -race

@danielgtaylor danielgtaylor added the bug Something isn't working label Jun 5, 2024
@danielgtaylor
Copy link
Owner

Thanks for reporting this! My initial suspicion is around re-use of the underlying data buffers via sync.Pool here, which we may need to defer putting back into the pool until after the handler has run: https://github.com/danielgtaylor/huma/blob/main/huma.go#L1289-L1290. I will do some testing on my side to confirm and fix ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants