public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kungfujesus06 at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/27227] Memory corruption for altivec unaligned load / store
Date: Fri, 22 Jan 2021 18:21:59 +0000	[thread overview]
Message-ID: <bug-27227-131-po8TMTFuPB@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27227-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27227

--- Comment #2 from Adam Stylinski <kungfujesus06 at gmail dot com> ---
(In reply to Andreas Schwab from comment #1)
> There is not a single memory write in your example, thus any memory
> corruption must have happened somewhere else.  In any case, nothing here
> looks related to glibc.  Try valgrind.

Sorry, that was definitely not a complete example, I was simply showing the
access pattern.  The memory writes are occurring in similar loops, where the
unaligned writes happen the same way as the loads, but the writes are handled
exactly as they were in Apple's documentation:

void StoreUnaligned( vector unsigned char src, void *target )
{

    vector unsigned char MSQ, LSQ;
    vector unsigned char mask, align, zero, neg1;
    MSQ = vec_ld(0, target);

    // most significant quadword
    LSQ = vec_ld(16, target);
    // least significant quadword
    align = vec_lvsr(0, target);
    // create alignment vector
    zero = vec_spat_u8( 0 );
    // Create vector full of zeros
    neg1 = vec_splat_s8( -1 );
    // Create vector full of -1
    mask=vec_perm(zero,neg1,align);
    Create select mask
    src=vec_perm(src,src,align );

    // Right rotate stored data
    MSQ = vec_sel( MSQ, src, mask );
    // Insert data into MSQ part
    LSQ = vec_sel( src, LSQ, mask );
   // Insert data into LSQ part
   vec_st( MSQ, 0, target );
   // Store the MSQ part
   vec_st( LSQ, 16, target );
   // Store the LSQ part
}

I'm asking first if my access pattern for both loads and stores is faulty to
begin with, or if something changed in glibc recently for the POWER ABI with
regard to alignment.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-01-22 18:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 17:45 [Bug malloc/27227] New: " kungfujesus06 at gmail dot com
2021-01-22 18:11 ` [Bug malloc/27227] " schwab@linux-m68k.org
2021-01-22 18:21 ` kungfujesus06 at gmail dot com [this message]
2021-01-22 20:36 ` fweimer at redhat dot com
2021-01-22 22:20 ` kungfujesus06 at gmail dot com
2021-01-22 22:23 ` kungfujesus06 at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27227-131-po8TMTFuPB@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).