Skip to content

Conversation

dktapps
Copy link
Contributor

@dktapps dktapps commented Sep 5, 2025

I have verified this fixes the assert issue locally, but I'm not sure if it may have side effects. Hopefully the build will tell.

@nielsdos
Copy link
Member

nielsdos commented Sep 5, 2025

Can you please resolve the merge conflict? Thanks!

@dktapps
Copy link
Contributor Author

dktapps commented Sep 5, 2025

Sorry, it's because the branch is based on PHP-8.4, I don't know why it conflicts with master. I'll resolve it later :)

I have verified this fixes the assert issue locally, but I'm not
sure if it may have side effects. Hopefully the build will tell.
@dktapps dktapps force-pushed the stream-select-assert branch from 0641281 to fabe490 Compare September 5, 2025 22:21
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

I think this is right. Probably this should also be applied to 8.3, but no need to retarget as we can pick this up into the right branch.
cc @cmb69 maybe you want to have a look as well?

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks reasonable to me, except for the issue mentioned below.

sock_max_fd = i;
}
} else {
handles[n_handles] = (HANDLE)(uintptr_t)_get_osfhandle(i);
Copy link
Member

Choose a reason for hiding this comment

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

I wonder wether an INVALID_HANDLE_VALUE can be returned here, and what to do in this case. Previously, that would have been treated as socket. Maybe we should stick with this; otherwise, it might be prudent to ignore such invalid handles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I hadn't considered that. I'm doubtful assuming it's a socket is a good idea since that might cause issues with socket-specific parts of the code. Probably best to just skip them.

WaitForMultipleObjects is told how many elements to read, and
it'll never read the element pointed to by n_handles, so we don't
need to initialize this.
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Looks good to me now.

Not quite sure about which branch to target; the bug only affects debug builds (and we don't ship those), and I'm always a bit uncomfortable changing some parts of the code base (like this one). I'm okay with targeting 8.3, though.

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

We can merge into master, since the assertion only affects debug builds. The fix for handling INVALID_HANDLE_VALUE may be valuable on lower branches too though. Perhaps we can merge first into master and if no problems arise merge it later into lower branches?

@nielsdos nielsdos linked an issue Sep 10, 2025 that may be closed by this pull request
@nielsdos nielsdos closed this in 36057b9 Sep 10, 2025
@nielsdos
Copy link
Member

I've merged this now and will keep an eye on this. Thanks!

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

Successfully merging this pull request may close these issues.

Windows: _get_osfhandle asserts in debug mode when given a socket

3 participants