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

bodies_by_type[SVt_PVNV]: handle __float128 NV alignment on 32-bit #22609

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from

Commits on Sep 24, 2024

  1. bodies_by_type[SVt_PVNV]: handle __float128 NV alignment on 32-bit

    Perl SV body structures include xmg_stash and xmg_u fields at the
    front, which are only valid for type SVt_PVMG and higher.
    
    This allows those fields to be at a constant offset from the start
    of the body.
    
    To save memory perl generally allocates the bodies where
    type < SVt_PVMG without the space needed for these two fields,
    offsetting the body pointer back by the size of the two fields.  At
    least for the first body in an arena this is technically
    undefined behaviour, but we've done it forever.
    
    With -msse __float128 requires 16 byte alignment, but for XPVNV
    bodies the hack used here means that the base of the XPVNV
    body ends up mis-aligned on 32-bit systems.
    
    On 64-bit systems the combined size of those fields is 16-bytes so
    the modified pointer is still properly aligned.
    
    To fix this allocate the full XPVNV structure when 16 byte alignment
    is required for NV, NV is more than 8 bytes and pointers are small
    enough that the NV would have been mis-aligned.
    
    Fixes Perl#22577
    tonycoz committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    ffbda81 View commit details
    Browse the repository at this point in the history