Skip to content

Fix #81407: shmop_open won't attach and causes php to crash #7448

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 3 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Sep 2, 2021

We need to allocate buffers for the file mapping names which are large
enough for all potential keys (key_t is defined as int on Windows).


A cleaner solution would be to print the keys as hexadecimal numbers, and to use 2*sizeof(key_t) to get its size. Not sure if anybody relies on the decimal keys; maybe better change that for "master" only?

And we may want to avoid the (likely harmless) integer overflow which currently may happen.

We need to allocate buffers for the file mapping names which are large
enough for all potential keys (`key_t` is defined as `int` on Windows).
@cmb69 cmb69 added the Bug label Sep 2, 2021
@nikic
Copy link
Member

nikic commented Sep 2, 2021

001+ Warning: shmop_open(): unable to attach or create shared memory segment 'File exists' in /Users/runner/work/1/s/ext/shmop/tests/bug81407.php on line 2
002+ 
003+ Warning: shmop_open(): unable to attach or create shared memory segment 'File exists' in /Users/runner/work/1/s/ext/shmop/tests/bug81407.php on line 3
004+ bool(false)
002- bool(true)

On azure.

It's probably never a good idea to use hard-coded keys (always use
`ftok()`), but to reliably reproduce this Windows specific issue we need
to, and it shouldn't be an issue on that OS.
@cmb69
Copy link
Member Author

cmb69 commented Sep 2, 2021

Ah, thanks! Guess it's best to run this test on Windows only.

Its string representation is longer than that of INT_MAX, and it's
permissible here.
@cmb69 cmb69 closed this in f3d24af Sep 2, 2021
@cmb69 cmb69 deleted the cmb/81407 branch September 2, 2021 21:23
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.

2 participants