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

mmap read is racy #4271

Closed
totaam opened this issue Jun 30, 2024 · 0 comments
Closed

mmap read is racy #4271

totaam opened this issue Jun 30, 2024 · 0 comments
Labels
bug Something isn't working client encoding

Comments

@totaam
Copy link
Collaborator

totaam commented Jun 30, 2024

It probably does not cause real problems because the mmap area is big enough that we don't overlap reads and writes.
09408c4 changed from array.from_buffer to memoryview but the result is the same: we have been using zero-copy since at least 2013: 2c3f04a

The fast-path using single-chunk encoding is preferred by the server side.
The client wraps this memory in a memoryview.

The problem is that the shared data offsets are updated synchronously:

data_start.value = offset + length

Instead, we should wait until the memoryview is freed before allowing writes to this area.
The lazy fix would be to call tobytes().
A better fix would be to obtain the memory pointer and use makebuf with a custom free function.

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

No branches or pull requests

1 participant