Skip to content

Add additional check for custom array/hash access checking #23399

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

Open
wants to merge 3 commits into
base: blead
Choose a base branch
from

Conversation

khwilliamson
Copy link
Contributor

@khwilliamson khwilliamson commented Jul 3, 2025

PL_check[] can have customized checks for array/hash elements in the
OP_AELEM, OP_EXISTS, and OP_DELETE elements. When these are set, the
multideref optimization is turned off.

It turns out that checking for this always shows that they are not the
standard values on z/OS, because that platform's function pointers may
point to a "function descriptor" and not the actual function, or it may
not. It's not clear to me if this implementation conforms to the C
Standard or not, but it is what it is. As a result our test suite fails
some tests that are expecting non-custom entries in those slots.

This commit builds upon some ideas from Dave Mitchell and Richard Leach
to add 3 entries to the array of function pointers. These entries are
initialized the same way the others are, so that a comparison against
them when no customization has been done should succeed.

The current comparisons are retained, so that it's likely on z/OS one or
the other will succeed when no customization is currently in place.

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

PL_check[] can have customized checks for array/hash elements in the
OP_AELEM, OP_EXISTS, and OP_DELETE elements.  When these are set, the
multideref optimization is turned off.

It turns out that checking for this always shows that they are not the
standard values on z/OS, because that platform's function pointers may
point to a "function descriptor" and not the actual function, or it may
not.  It's not clear to me if this implementation conforms to the C
Standard or not, but it is what it is.  As a result our test suite fails
some tests that are expecting non-custom entries in those slots.

This commit builds upon some ideas from Dave Mitchell and Richard Leach
to add 3 entries to the array of function pointers.  These entries are
initialized the same way the others are, so that a comparison against
them when no customization has been done should succeed.

The current comparisons are retained, so that it's likely on z/OS one or
the other will succeed when no customization is currently in place.
I imagine most compilers would know to optimize the reference away when
the first conditional has ruled out all but one possibility, but I think
it is clearer anyway to use that single value.
It's also unlikely that the op_type will be any given value, but I
expect the compiler and libc know that.

This stresses that it is unlikely some module will customize the
handling of these checkers.
@khwilliamson khwilliamson requested a review from iabyn July 3, 2025 21:01
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.

1 participant