-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Modify conservative GC code for unaligned InlinedCallFrames #1215
Conversation
@jkotas would be a better person to review this as this is stackwalking code. |
I think you should make the InlinedCallFrame 8-byte aligned even with conservative GC instead of trying to compensate for it in the runtime. The alignment should naturally fall out: InlinedCallFrame has pointer sized fields that you are filling in. These pointer sized fields should cause the right alignment to happen. |
Making the As far as alignment goes: I agree that 8-byte aligning |
Fixing the assumption about The alignment for |
When making pinvoke calls the JITs allocate InlinedCallFrames within their stack frames to record the location of the managed stack frame. These InlinedCallFrames are not necessarily 8-byte aligned. These were being used as the topStack in src/vm/gcenv.cpp, in the method GCToEEInterface::ScanStackRoots. This change checks to see if a frame is an InlinedCallFrame. If so then its GetCallSiteSP method is used to get the real top of stack. This will always be aligned. There were two problem before this change wwhen the frame was misaligned (e.g. ending with 4 or c): 1. GCToEEInterface::ScanStackRoots starts at the topStack and look at every 8-byte chunk as if it were a pointer. But if topStack is unaligned it is not really finding the pointers on the stack. 2. When it gets to the bottom the 8-byte access read the first 4 bytes ok, but the last 4 bytes go beyond mapped addresses and an access violation results.
I've updated the PR description so that the issue being solved is that |
I've pushed a rebase of the change. |
LGTM. Thanks! |
Modify conservative GC code for unaligned InlinedCallFrames
When making pinvoke calls the JITs allocate InlinedCallFrames
within their stack frames to record the location
of the managed stack frame. These were being used
as the topStack in src/vm/gcenv.cpp, in the method
GCToEEInterface::ScanStackRoots. But they are not
really the top of the stack, but they can be used to find
the real top of the stack.
This change checks to see if a frame is an InlinedCallFrame.
If so then its GetCallSiteSP method is used to
get the real top of stack.