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

Fix setting pipe used in PAL_ProbeMemory as nonblocking #61126

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/coreclr/pal/src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,15 +742,19 @@ PAL_ProbeMemory(
BOOL fWriteAccess)
{
int fds[2];
int flags;

if (pipe(fds) != 0)
{
ASSERT("pipe failed: errno is %d (%s)\n", errno, strerror(errno));
return FALSE;
}

fcntl(fds[0], O_NONBLOCK);
fcntl(fds[1], O_NONBLOCK);
flags = fcntl(fds[0], F_GETFL, 0);
fcntl(fds[0], F_SETFL, flags | O_NONBLOCK);
Comment on lines +753 to +754
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an alternative would be using pipe2 but this would require an #ifdef

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do some targets not support pipe2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipe2 is Linux-specific and we support macOS and few other Unix-like OSese. The current solution is good, I am going to merge the PR.


flags = fcntl(fds[1], F_GETFL, 0);
fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);

PVOID pEnd = (PBYTE)pBuffer + cbBuffer;
BOOL result = TRUE;
Expand Down