Skip to content

MY_CXT: don't SEGV on a 1-byte struct. #23309

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

Merged
merged 1 commit into from
May 22, 2025
Merged

MY_CXT: don't SEGV on a 1-byte struct. #23309

merged 1 commit into from
May 22, 2025

Conversation

iabyn
Copy link
Contributor

@iabyn iabyn commented May 20, 2025

The MY_CXT mechanism allows XS code to declare a 'static' struct which is actually per-interpreter. Behind the scenes, the memory for this struct is allocated as the PVX buf of an SV. If the size of the struct is 1 (e.g. '{ char foo }' ) then newSV(size-1) gets called as newSV(0), which skips allocating a PVX buffer. SEGVs ensue.

  • This set of changes does not require a perldelta entry.

The MY_CXT mechanism allows XS code to declare a 'static' struct
which is actually per-interpreter. Behind the scenes, the memory for
this struct is allocated as the PVX buf of an SV. If the size of the
struct is 1 (e.g. '{ char foo }' ) then newSV(size-1) gets called
as newSV(0), which skips allocating a PVX buffer. SEGVs ensue.
@richardleach
Copy link
Contributor

LGTM.

@ap ap merged commit 9cc0eeb into blead May 22, 2025
68 checks passed
@ap
Copy link
Contributor

ap commented May 22, 2025

Thanks Dave.

@iabyn iabyn deleted the davem/cxt branch May 23, 2025 09:24
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.

4 participants