-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CEE_CALL yielding invalid address call instruction on win64 #44397
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
The area is area-CodeGen-coreclr |
Is the address the jit is calling the one that is returned in the |
The struct returns the address of the pointer to the function. void get_call_info(CORINFO_CALL_INFO *pResult) override {
pResult->codePointerLookup.lookupKind.needsRuntimeLookup = false;
// TODO: If we use IAT_VALUE we need to generate a jump stub
pResult->codePointerLookup.constLookup.accessType = IAT_PVALUE;
pResult->codePointerLookup.constLookup.addr = &m_addr;
pResult->verMethodFlags = pResult->methodFlags = CORINFO_FLG_STATIC;
pResult->kind = CORINFO_CALL;
pResult->sig.args = (CORINFO_ARG_LIST_HANDLE)(m_params.size() == 0 ? nullptr : &m_params[0]);
pResult->sig.retType = m_retType;
pResult->sig.numArgs = m_params.size();
} The debugger can see the symbols for m_addr when I put a breakpoint on the line
That generated the machine instructions: (I can see the value farther down in The invalid call instruction is the 5th down from the preamble (
|
After some more digging, I think that is a callback for CORINFO_HELP_STACK_PROBE. |
@AndyAyersMS what is the correct signature for I think its a signature mismatch and |
It does not have a standard calling convention. It takes an argument in R11 and doesn't return anything. You can likely get pretty far by just defining it as If you need to implement it you will need something like the below; the only way to define it is via assembly. runtime/src/coreclr/src/vm/amd64/JitHelpers_Fast.asm Lines 400 to 424 in 1c1757c
|
I've tried reimplementing JIT_StackProbe in a simple MASM file and linking it to be returned back. As soon as |
One thing to check -- since you are returning That is, some thing like
|
The solution was to use the indirection pointer in |
The stack overflows might just be from asking for too much stack, and not a bug per se. On windows you have 1MB stack segments by default. Can you debug into the failure and see if you're trying to go beyond that limit? |
This is where I got the overflow. Looking at where the helper is called, R11 is the proposed stack depth?
Registers were
The procedure is borrowed from JitHelpers_fast.asm, which seemed to be the correct MASM/x64 proc
|
The code in the helper initially sets If you set |
Noticed that the stack frame is requested as a delta of the page size, from This is working now. thanks again |
Good to hear. That's an impressive amount of work you have built up over in microsoft/Pyjion#237 -- 280 commits! |
Those final changes were enough to get the Python test suite passing on macOS, Linux and Windows for .NET5RC2. Look forward to patching this to GA |
This relates directly to RyuJIT and the emitter for CEE_CALL to a IAT_PVALUE global method.
I'm working on a project that uses only the JIT and compiles CIL to native code.
When calling Global Static methods, the executable is crashing because the JIT is generating invalid
call
instructions. The call addresses are valid in macOS and Linux, but in Windows they point to an invalid memory address.When debugging I can see that the call to getCallInfo will return a
CORINFO_CALL_INFO
struct with the fieldcodePointerLookup.constLookup.addr
at the correct memory address of the compiled function. The method has the flagsCORINFO_FLG_STATIC
However, when the Jitted code executes it will start running through the correct machine code instructions and raises an access violation on the
call
. The Windows debugger shows that the memory address it tried to call is not executable code.This code works perfectly on macOS and Linux, so there must be something about the virtual memory addresses in Windows, or a missing indirection?
If someone could help, that would be great. The code is here microsoft/Pyjion#237
Configuration
Regression?
Yes, this worked on a very old version of .NET core 1.0
Other information
@AndyAyersMS helped on this project last time (issue #42925). It's working brilliantly on macOS and Linux now.
The text was updated successfully, but these errors were encountered: