summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaeHie Park <saehie.park@gmail.com>2017-02-16 17:50:08 +0900
committerJan Vorlicek <janvorli@microsoft.com>2017-02-16 09:50:08 +0100
commitf8e6123ca24475cff7d78ff234c2cfd67e9e9772 (patch)
tree9ad08d0a8ef96701baf0f05d2417b92f28986111
parenta9b25d4aa22a1f4ad5f323f6c826e318f5a720fe (diff)
downloadcoreclr-f8e6123ca24475cff7d78ff234c2cfd67e9e9772.tar.gz
coreclr-f8e6123ca24475cff7d78ff234c2cfd67e9e9772.tar.bz2
coreclr-f8e6123ca24475cff7d78ff234c2cfd67e9e9772.zip
[x86/Linux] Fix IsIPInMarkedJitHelper to handle sigsegv (#9605)
Include JIT_WriteBarrier and JIT_CheckedWriteBarrier functions so that we can handle NullReferenceException for sigsegv from WriteBarriers.
-rw-r--r--src/vm/excep.cpp9
-rw-r--r--src/vm/i386/jithelp.S30
-rw-r--r--src/vm/i386/jithelp.asm29
-rw-r--r--src/vm/i386/jitinterfacex86.cpp12
-rw-r--r--src/vm/jitinterface.h8
5 files changed, 40 insertions, 48 deletions
diff --git a/src/vm/excep.cpp b/src/vm/excep.cpp
index 7fca6f02e7..a9c38eee2f 100644
--- a/src/vm/excep.cpp
+++ b/src/vm/excep.cpp
@@ -7072,6 +7072,11 @@ bool IsIPInMarkedJitHelper(UINT_PTR uControlPc)
CHECK_RANGE(JIT_WriteBarrier)
CHECK_RANGE(JIT_CheckedWriteBarrier)
+#else
+#ifdef FEATURE_PAL
+ CHECK_RANGE(JIT_WriteBarrierGroup)
+ CHECK_RANGE(JIT_PatchedWriteBarrierGroup)
+#endif // FEATURE_PAL
#endif // _TARGET_X86_
#if defined(_TARGET_AMD64_) && defined(_DEBUG)
@@ -7097,8 +7102,8 @@ AdjustContextForWriteBarrier(
#if defined(_TARGET_X86_) && !defined(PLATFORM_UNIX)
void* f_IP = (void *)GetIP(pContext);
- if (((f_IP >= (void *) JIT_WriteBarrierStart) && (f_IP <= (void *) JIT_WriteBarrierLast)) ||
- ((f_IP >= (void *) JIT_PatchedWriteBarrierStart) && (f_IP <= (void *) JIT_PatchedWriteBarrierLast)))
+ if (((f_IP >= (void *) JIT_WriteBarrierGroup) && (f_IP <= (void *) JIT_WriteBarrierGroup_End)) ||
+ ((f_IP >= (void *) JIT_PatchedWriteBarrierGroup) && (f_IP <= (void *) JIT_PatchedWriteBarrierGroup_End)))
{
// set the exception IP to be the instruction that called the write barrier
void* callsite = (void *)GetAdjustedCallAddress(*dac_cast<PTR_PCODE>(GetSP(pContext)));
diff --git a/src/vm/i386/jithelp.S b/src/vm/i386/jithelp.S
index 9a7e3344cd..d7cbba09ee 100644
--- a/src/vm/i386/jithelp.S
+++ b/src/vm/i386/jithelp.S
@@ -371,12 +371,12 @@ NESTED_END JIT_ByRefWriteBarrier, _TEXT
.endm
-// WriteBarrierStart and WriteBarrierEnd are used to determine bounds of
-// WriteBarrier functions so can determine if got AV in them.
+// JIT_WriteBarrierGroup and JIT_WriteBarrierGroup_End are used
+// to determine bounds of WriteBarrier functions so can determine if got AV in them.
//
-LEAF_ENTRY JIT_WriteBarrierStart, _TEXT
+LEAF_ENTRY JIT_WriteBarrierGroup, _TEXT
ret
-LEAF_END JIT_WriteBarrierStart, _TEXT
+LEAF_END JIT_WriteBarrierGroup, _TEXT
#ifdef FEATURE_USE_ASM_GC_WRITE_BARRIERS
// *******************************************************************************
@@ -408,14 +408,10 @@ WriteBarrierHelper EBP
ByRefWriteBarrierHelper
-LEAF_ENTRY JIT_WriteBarrierLast, _TEXT
- ret
-LEAF_END JIT_WriteBarrierLast, _TEXT
-
// This is the first function outside the "keep together range". Used by BBT scripts.
-LEAF_ENTRY JIT_WriteBarrierEnd, _TEXT
+LEAF_ENTRY JIT_WriteBarrierGroup_End, _TEXT
ret
-LEAF_END JIT_WriteBarrierEnd, _TEXT
+LEAF_END JIT_WriteBarrierGroup_End, _TEXT
// *********************************************************************/
// In cases where we support it we have an optimized GC Poll callback.
@@ -688,9 +684,9 @@ LEAF_END JIT_PatchedCodeStart, _TEXT
// **********************************************************************
// Write barriers generated at runtime
-LEAF_ENTRY JIT_PatchedWriteBarrierStart, _TEXT
+LEAF_ENTRY JIT_PatchedWriteBarrierGroup, _TEXT
ret
-LEAF_END JIT_PatchedWriteBarrierStart, _TEXT
+LEAF_END JIT_PatchedWriteBarrierGroup, _TEXT
.macro PatchedWriteBarrierHelper rg
.align 8
@@ -708,15 +704,11 @@ PatchedWriteBarrierHelper ESI
PatchedWriteBarrierHelper EDI
PatchedWriteBarrierHelper EBP
-LEAF_ENTRY JIT_PatchedWriteBarrierLast, _TEXT
+// This is the first function outside the "keep together range". Used by BBT scripts.
+LEAF_ENTRY JIT_PatchedWriteBarrierGroup_End, _TEXT
ret
-LEAF_END JIT_PatchedWriteBarrierLast, _TEXT
+LEAF_END JIT_PatchedWriteBarrierGroup_End, _TEXT
LEAF_ENTRY JIT_PatchedCodeLast, _TEXT
ret
LEAF_END JIT_PatchedCodeLast, _TEXT
-
-// This is the first function outside the "keep together range". Used by BBT scripts.
-LEAF_ENTRY JIT_PatchedCodeEnd, _TEXT
- ret
-LEAF_END JIT_PatchedCodeEnd, _TEXT
diff --git a/src/vm/i386/jithelp.asm b/src/vm/i386/jithelp.asm
index 8285c42455..e8d2f121e0 100644
--- a/src/vm/i386/jithelp.asm
+++ b/src/vm/i386/jithelp.asm
@@ -434,10 +434,10 @@ ENDM
; WriteBarrierStart and WriteBarrierEnd are used to determine bounds of
; WriteBarrier functions so can determine if got AV in them.
;
-PUBLIC _JIT_WriteBarrierStart@0
-_JIT_WriteBarrierStart@0 PROC
+PUBLIC _JIT_WriteBarrierGroup@0
+_JIT_WriteBarrierGroup@0 PROC
ret
-_JIT_WriteBarrierStart@0 ENDP
+_JIT_WriteBarrierGroup@0 ENDP
ifdef FEATURE_USE_ASM_GC_WRITE_BARRIERS
; Only define these if we're using the ASM GC write barriers; if this flag is not defined,
@@ -455,16 +455,11 @@ WriteBarrierHelper <EBP>
ByRefWriteBarrierHelper
-PUBLIC _JIT_WriteBarrierLast@0
-_JIT_WriteBarrierLast@0 PROC
-ret
-_JIT_WriteBarrierLast@0 ENDP
-
; This is the first function outside the "keep together range". Used by BBT scripts.
-PUBLIC _JIT_WriteBarrierEnd@0
-_JIT_WriteBarrierEnd@0 PROC
+PUBLIC _JIT_WriteBarrierGroup_End@0
+_JIT_WriteBarrierGroup_End@0 PROC
ret
-_JIT_WriteBarrierEnd@0 ENDP
+_JIT_WriteBarrierGroup_End@0 ENDP
;*********************************************************************/
; In cases where we support it we have an optimized GC Poll callback. Normall (when we're not trying to
@@ -2345,10 +2340,10 @@ endif
;**********************************************************************
; Write barriers generated at runtime
-PUBLIC _JIT_PatchedWriteBarrierStart@0
-_JIT_PatchedWriteBarrierStart@0 PROC
+PUBLIC _JIT_PatchedWriteBarrierGroup@0
+_JIT_PatchedWriteBarrierGroup@0 PROC
ret
-_JIT_PatchedWriteBarrierStart@0 ENDP
+_JIT_PatchedWriteBarrierGroup@0 ENDP
PatchedWriteBarrierHelper MACRO rg
ALIGN 8
@@ -2367,10 +2362,10 @@ PatchedWriteBarrierHelper <ESI>
PatchedWriteBarrierHelper <EDI>
PatchedWriteBarrierHelper <EBP>
-PUBLIC _JIT_PatchedWriteBarrierLast@0
-_JIT_PatchedWriteBarrierLast@0 PROC
+PUBLIC _JIT_PatchedWriteBarrierGroup_End@0
+_JIT_PatchedWriteBarrierGroup_End@0 PROC
ret
-_JIT_PatchedWriteBarrierLast@0 ENDP
+_JIT_PatchedWriteBarrierGroup_End@0 ENDP
_JIT_PatchedCodeLast@0 proc public
ret
diff --git a/src/vm/i386/jitinterfacex86.cpp b/src/vm/i386/jitinterfacex86.cpp
index 9af3a3ce20..89b0cf7604 100644
--- a/src/vm/i386/jitinterfacex86.cpp
+++ b/src/vm/i386/jitinterfacex86.cpp
@@ -1509,8 +1509,8 @@ void InitJITHelpers1()
// All write barrier helpers should fit into one page.
// If you hit this assert on retail build, there is most likely problem with BBT script.
- _ASSERTE_ALL_BUILDS("clr/src/VM/i386/JITinterfaceX86.cpp", (BYTE*)JIT_WriteBarrierLast - (BYTE*)JIT_WriteBarrierStart < PAGE_SIZE);
- _ASSERTE_ALL_BUILDS("clr/src/VM/i386/JITinterfaceX86.cpp", (BYTE*)JIT_PatchedWriteBarrierLast - (BYTE*)JIT_PatchedWriteBarrierStart < PAGE_SIZE);
+ _ASSERTE_ALL_BUILDS("clr/src/VM/i386/JITinterfaceX86.cpp", (BYTE*)JIT_WriteBarrierGroup_End - (BYTE*)JIT_WriteBarrierGroup < PAGE_SIZE);
+ _ASSERTE_ALL_BUILDS("clr/src/VM/i386/JITinterfaceX86.cpp", (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup < PAGE_SIZE);
// Copy the write barriers to their final resting place.
for (int iBarrier = 0; iBarrier < NUM_WRITE_BARRIERS; iBarrier++)
@@ -1690,8 +1690,8 @@ void StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */)
}
if (flushICache)
- FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierStart,
- (BYTE*)JIT_PatchedWriteBarrierLast - (BYTE*)JIT_PatchedWriteBarrierStart);
+ FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierGroup,
+ (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup);
}
/*********************************************************************/
@@ -1827,8 +1827,8 @@ void StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck)
}
else
{
- FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierStart,
- (BYTE*)JIT_PatchedWriteBarrierLast - (BYTE*)JIT_PatchedWriteBarrierStart);
+ FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierGroup,
+ (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup);
}
if(bEESuspendedHere)
diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h
index d6dd5d2e65..978be03ee4 100644
--- a/src/vm/jitinterface.h
+++ b/src/vm/jitinterface.h
@@ -378,11 +378,11 @@ extern "C"
void STDCALL JIT_WriteBarrierEDI(); // JIThelp.asm/JIThelp.s
void STDCALL JIT_WriteBarrierEBP(); // JIThelp.asm/JIThelp.s
- void STDCALL JIT_WriteBarrierStart();
- void STDCALL JIT_WriteBarrierLast();
+ void STDCALL JIT_WriteBarrierGroup();
+ void STDCALL JIT_WriteBarrierGroup_End();
- void STDCALL JIT_PatchedWriteBarrierStart();
- void STDCALL JIT_PatchedWriteBarrierLast();
+ void STDCALL JIT_PatchedWriteBarrierGroup();
+ void STDCALL JIT_PatchedWriteBarrierGroup_End();
}
void ValidateWriteBarrierHelpers();