Skip to content

Support shmget(IPC_PRIVATE, …) on Windows #5519

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

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented May 3, 2020

We map the POSIX semantics of IPC_PRIVATE by creating unnamed file
mapping objects on Windows. While that is not particularly useful for
ext/shmop, which is the only bundled extension which uses shmget(),
and even constitutes a potential BC break for shmop_open(), it may
be useful for external extensions.

@nikic
Copy link
Member

nikic commented May 3, 2020

Can we test this?

@cmb69 cmb69 marked this pull request as draft May 4, 2020 09:02
We map the POSIX semantics of `IPC_PRIVATE` by creating unnamed file
mapping objects on Windows.  While that is not particularly useful for
ext/shmop, which is the only bundled extension which uses `shmget()`,
it may be useful for external extensions.
@cmb69 cmb69 force-pushed the cmb/ipc-private branch from 4071b68 to 25d7cf9 Compare May 5, 2020 07:47
@cmb69 cmb69 marked this pull request as ready for review May 5, 2020 07:48
@cmb69
Copy link
Member Author

cmb69 commented May 5, 2020

Can we test this?

I added a test to verify that private SHM is private. Adding a test to verify that private SHM can be shared between threads would likely require to have a suitable SAPI available.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

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

Looks reasonable.

Do you think it would make sense to apply this to 7.3 as well? I see this as a bug fix in Unix emulation.

@cmb69
Copy link
Member Author

cmb69 commented May 5, 2020

I also see this as bug fix, and applying to PHP 7.3 would be helpful for APCu (and maybe some other extensions), but I'm somewhat concerned about the BC break for existing code calling shmop(0, …) without assuming this is supposed to be private. On the other hand, ext/shmop might be rarely used.

Somewhat related: shouldn't we introduce a constant to make IPC_PRIVATE available to userland? Say, PHP_IPC_PRIVATE.

@nikic
Copy link
Member

nikic commented May 5, 2020

I also see this as bug fix, and applying to PHP 7.3 would be helpful for APCu (and maybe some other extensions), but I'm somewhat concerned about the BC break for existing code calling shmop(0, …) without assuming this is supposed to be private. On the other hand, ext/shmop might be rarely used.

As they would already see that behavior on Linux, I don't think this is a problem. Using shmop() as Windows-only functionality seems somewhat unusual to me.

Somewhat related: shouldn't we introduce a constant to make IPC_PRIVATE available to userland? Say, PHP_IPC_PRIVATE.

Agree.

@cmb69
Copy link
Member Author

cmb69 commented May 5, 2020

Well, I think you're right, so I've filed https://bugs.php.net/79566.

For PHP_IPC_PRIVATE: see PR #5527.

@cmb69
Copy link
Member Author

cmb69 commented May 5, 2020

Applied as f33cf52. Thanks!

@cmb69 cmb69 closed this May 5, 2020
@cmb69 cmb69 deleted the cmb/ipc-private branch May 5, 2020 09:43
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.

2 participants