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

doio: fix shmread() on non-string buffers #22900

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jan 9, 2025

  • If the buffer is a reference, don't leak memory (or abort, on debugging perls). The problem is that SvPOK_only() blindly turns off some SV flags, but does not decrement any refcounts if ROK was on.
  • If the buffer is tied, don't call FETCH. Conceptually, shmread() is a bytestring assignment (from a shared memory segment to a scalar variable), so it should only STORE. (This is also why most of the code can be replaced by sv_setpvn().)

Fixes #22898.


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

- If the buffer is a reference, don't leak memory (or abort, on
  debugging perls). The problem is that SvPOK_only() blindly turns off
  some SV flags, but does not decrement any refcounts if ROK was on.
- If the buffer is tied, don't call FETCH. Conceptually, shmread() is a
  bytestring assignment (from a shared memory segment to a scalar
  variable), so it should only STORE. (This is also why most of the code
  can be replaced by sv_setpvn().)

Fixes Perl#22898.
@tonycoz
Copy link
Contributor

tonycoz commented Jan 9, 2025

I suspect this behaved badly with COW SVs too.

@mauke mauke merged commit 3a16cb5 into Perl:blead Jan 9, 2025
33 of 34 checks passed
@mauke mauke deleted the fix-22898-shmread branch January 9, 2025 06:58
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.

shmread() on tied buffer calls FETCH for no reason
2 participants