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

doc: minor clarification about safe memory access #4126

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

N7Alpha
Copy link

@N7Alpha N7Alpha commented Aug 23, 2023

Regarding Windows the documentation for uv_write is incorrect.

From the WSASend documentation on MSDN

[in] lpBuffers
A pointer to an array of WSABUF structures. Each WSABUF structure contains a pointer to a buffer and the length, in bytes, of the buffer. For a Winsock application, once the WSASend function is called, the system owns these buffers and the application may not access them. This array must remain valid for the duration of the send operation.

The problem is uv_write invokes WSASend asynchronously so in the meantime you can't access the buffers you give it. uv_write says they must "remain valid" which is kind of ambiguous and sounds like they shouldn't be freed or something.

This made a data race out of what I thought was a benign race condition in my code. I only realized this after looking through the implementation of uv_write.

Also I realize this is from the unix implementation file and things might be different on POSIX systems, but this is the documentation that's part of the autodocs for all platforms.

Feel free to change the wording of the documentation however you like, I'd just like it to get the point across.

@vtjnash vtjnash added the doc label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants