[LLVMbugs] [Bug 16248] movaps used for unaligned memory involving va_list and nested structs

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 10 17:59:20 PDT 2013


Justin Bogner <llvm-bugs at justinbogner.com> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #3 from Justin Bogner <llvm-bugs at justinbogner.com> ---
While this doesn't segfault anymore, it doesn't seem to do the right thing. The
value that comes out of va_arg is garbage from somewhere nearby on the stack.

Here's the program from before with a main added to demonstrate:

    #include <stdarg.h>
    #include <stdio.h>
    #include <inttypes.h>

    typedef struct Uuid128 {
        __uint128_t __uint;
    } Uuid128_t;

    typedef struct SiteUuid {
      Uuid128_t   su_uuid;
    } SiteUuid_t;

    vloadSiteUuid(void *entryRef, va_list argList)
        SiteUuid_t *su = entryRef;

        su->su_uuid = va_arg(argList, Uuid128_t);

    loadSiteUuid(void *entryRef, ...)
        va_list args;

        va_start(args, entryRef);
        vloadSiteUuid(entryRef, args);

    main(int argc, const char *argv[])
        SiteUuid_t Buf;
        Uuid128_t uuid = {
            (__uint128_t)0x0f0e0d0c0b0a0908 << 64 | 0x0706050403020100

        printf("%016" PRIx64 "%016" PRIx64 "\n",
               (uint64_t)(uuid.__uint >> 64),
        // prints 0f0e0d0c0b0a09080706050403020100

        loadSiteUuid(&Buf, uuid);

        printf("%016" PRIx64 "%016" PRIx64 "\n",
               (uint64_t)(Buf.su_uuid.__uint >> 64),
        // does not print 0f0e0d0c0b0a09080706050403020100

When I disassembled the relevant function in my bigger program, I could see the
correct value in two places on the stack, one of which was aligned, but the
value returned was 0x60 away from there.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130611/3c19d381/attachment.html>

More information about the llvm-bugs mailing list