This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vladris
Recipients Abraham.Soedjito, cgohlke, jwhitecl, santoso.wijaya, theller, vladris
Date 2011-08-14.20:46:19
SpamBayes Score 1.7434155e-09
Marked as misclassified No
Message-id <>
Attached patch for this issue.

This only happens on MSVC x64 (I actually tired to repro on Arch Linux x64 before starting work on it and it didn't repro).

What happens is that MSVC on x64 always passes structures larger than 8 bytes by reference. See here:

Now this was accounted for in callproc.c, line 1143 in development branch with this:

        if (atypes[i]->type == FFI_TYPE_STRUCT
#ifdef _WIN64
            && atypes[i]->size <= sizeof(void *)
            avalues[i] = (void *)args[i].value.p;
            avalues[i] = (void *)&args[i].value;

This fix wasn't made in libffi_msvc/ffi.c though. Here, regardless of whether we have x64 or x86 build, if z >= sizeof(int) we will hit else branch in libffi_msvc/ffi.c at line 114 and do:

	  memcpy(argp, *p_argv, z);
      argp += z;

In our case, we copy 28 bytes as arguments (size of our structure) but in fact for x64 we only need 8 as structure is passed by reference so argument is just a pointer. My patch will adjust z before hitting if statement on x64 and it will cause correct copy as pointer.
Date User Action Args
2011-08-14 20:46:20vladrissetrecipients: + vladris, theller, cgohlke, santoso.wijaya, Abraham.Soedjito, jwhitecl
2011-08-14 20:46:20vladrissetmessageid: <>
2011-08-14 20:46:20vladrislinkissue11835 messages
2011-08-14 20:46:19vladriscreate