Thunking problems with arch issues

Hiemlick Hiemlicker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 2 11:59:14 PDT 2016


On Saturday, 2 July 2016 at 01:51:03 UTC, rikki cattermole wrote:
> Couple of things could be happening.
>
> 1) Alignments are off, aligning of data really really matters
Where? I rewrote the code to use size_t and same problem. If 
alignments were off chances are it wouldn't exhibit the issues in 
the way it does(work fine for 64 and not 86, not for ldc).
> when dealing with executable code.
> 2) For Windows only. Don't forget to call 
> FlushInstructionCache. Before executing. 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms679350(v=vs.85).aspx
Tried, didn't work.

> 3) Don't use new to get your executable memory, nope nope nope. 
> Use things like VirtualAlloc as malloc doesn't work right see 
> the first point.

Well..

I see these as general statements that don't actually address the 
real problem in the code. I rewrote the code and it has the same 
problem. I see no reason why it shouldn't work.

It does not manipulate the code, and new seems to allocate 
aligned(if not it would work some of the time and fail others).

It specifically has the problem when used as a windows callback. 
I guess it has to do with the calling convention.



Here is the complete test code:


https://dpaste.dzfl.pl/d8cea3b39d0d





More information about the Digitalmars-d-learn mailing list