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

make shmread/shmwrite work with args beyond I32/2GB #22897

Merged
merged 4 commits into from
Jan 8, 2025
Merged

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jan 8, 2025

Extend mpos/msize to the full size_t/STRLEN range (whatever that is on the current platform).

Tests included.

Fixes #22895.


  • This set of changes requires a perldelta entry, and it is included.

mauke added 2 commits January 8, 2025 11:46
PERL_ARGS_ASSERT_DO_SHMIO is equivalent to `assert(mark); assert(sp)`.
There is no point in checking pointers that have already been
dereferenced by previous statements. An optimizing compiler will simply
remove those asserts as no-ops.

Move the asserts up to before any of the function arguments are used.
- Extend mpos/msize to the full size_t/STRLEN range (whatever that is on
  the current platform).
- Fully validate the range of all incoming values, including making sure
  that mpos+misze does not overflow (I think you used to be able to
  crash perl with this before).
- Assert that the optype is either OP_SHMREAD or OP_SHMWRITE (because the
  code blindly performs a shmwrite() if optype is not OP_SHMREAD).
- Switch to Perl_croak_nocontext because why not.

Fixes Perl#22895.
mauke added 2 commits January 8, 2025 18:36
Guard tests behind PERL_TEST_MEMORY because we're allocating a 2GB
shared mem segment and a 2GB scalar buffer. These tests used to fail (or
crash) before the do_shmio() I32 fixes.

Also fix the error message if the initial shmget fails
("IPC::SharedMem->new" was a copy/paste oversight from when these tests
were copied in from IPC::SysV in 2d5385e).

Also test that shmwrite() from a tied buffer only calls FETCH once while
we're at it.
@mauke
Copy link
Contributor Author

mauke commented Jan 8, 2025

I missed a piece of debugging code in the test (... or diag("$!")). Now removed and force-pushed.

@mauke mauke merged commit cb62cc5 into Perl:blead Jan 8, 2025
32 of 33 checks passed
@mauke mauke deleted the fix-shmio branch January 8, 2025 23:12
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.

shmwrite function only supports POS or SIZE values < 2^31
2 participants