Message142083
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: http://msdn.microsoft.com/en-us/library/ms235286(v=vs.90).aspx
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 *)
#endif
)
avalues[i] = (void *)args[i].value.p;
else
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:
else
{
memcpy(argp, *p_argv, z);
}
p_argv++;
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:20 | vladris | set | recipients:
+ vladris, theller, cgohlke, santoso.wijaya, Abraham.Soedjito, jwhitecl |
2011-08-14 20:46:20 | vladris | set | messageid: <1313354780.62.0.95129727948.issue11835@psf.upfronthosting.co.za> |
2011-08-14 20:46:20 | vladris | link | issue11835 messages |
2011-08-14 20:46:19 | vladris | create | |
|