-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove most usages of the macro-based "don't return in this block" hack #113856
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
Changes from 9 commits
4af9a47
512c338
0f07989
aa8002c
24e6f34
f581f23
6cc3ecd
42fb90e
666af8e
c36e9d8
0af13da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -342,8 +342,7 @@ VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHar | |
| bool __fExceptionCaught = false; \ | ||
| SCAN_EHMARKER(); \ | ||
| if (true) PAL_CPP_TRY { \ | ||
| SCAN_EHMARKER_TRY(); \ | ||
| DEBUG_ASSURE_NO_RETURN_BEGIN(IUACH) | ||
| SCAN_EHMARKER_TRY(); | ||
|
|
||
| #define INSTALL_UNWIND_AND_CONTINUE_HANDLER \ | ||
| INSTALL_UNWIND_AND_CONTINUE_HANDLER_EX \ | ||
|
|
@@ -358,11 +357,9 @@ VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHar | |
| bool __fExceptionCaught = false; \ | ||
| SCAN_EHMARKER(); \ | ||
| if (true) PAL_CPP_TRY { \ | ||
| SCAN_EHMARKER_TRY(); \ | ||
| DEBUG_ASSURE_NO_RETURN_BEGIN(IUACH); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing in the enclosing block in the |
||
| SCAN_EHMARKER_TRY(); | ||
|
|
||
| #define UNINSTALL_UNWIND_AND_CONTINUE_HANDLER_EX(nativeRethrow) \ | ||
| DEBUG_ASSURE_NO_RETURN_END(IUACH) \ | ||
| SCAN_EHMARKER_END_TRY(); \ | ||
| } \ | ||
| PAL_CPP_CATCH_NON_DERIVED_NOARG (const std::bad_alloc&) \ | ||
|
|
@@ -500,12 +497,12 @@ void COMPlusCooperativeTransitionHandler(Frame* pFrame); | |
| { \ | ||
| MAKE_CURRENT_THREAD_AVAILABLE(); \ | ||
| BEGIN_GCX_ASSERT_PREEMP; \ | ||
| CoopTransitionHolder __CoopTransition(CURRENT_THREAD); \ | ||
| DEBUG_ASSURE_NO_RETURN_BEGIN(COOP_TRANSITION) | ||
| { \ | ||
| CoopTransitionHolder __CoopTransition(CURRENT_THREAD); | ||
|
|
||
| #define COOPERATIVE_TRANSITION_END() \ | ||
| DEBUG_ASSURE_NO_RETURN_END(COOP_TRANSITION) \ | ||
| __CoopTransition.SuppressRelease(); \ | ||
| __CoopTransition.SuppressRelease(); \ | ||
| } \ | ||
| END_GCX_ASSERT_PREEMP; \ | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2819,36 +2819,6 @@ class ExceptionFilterFrame : public Frame | |
| #endif | ||
| }; | ||
|
|
||
| #ifdef _DEBUG | ||
| // We use IsProtectedByGCFrame to check if some OBJECTREF pointers are protected | ||
| // against GC. That function doesn't know if a byref is from managed stack thus | ||
| // protected by JIT. AssumeByrefFromJITStackFrame is used to bypass that check if an | ||
| // OBJECTRef pointer is passed from managed code to an FCall and it's in stack. | ||
|
|
||
| typedef DPTR(class AssumeByrefFromJITStackFrame) PTR_AssumeByrefFromJITStackFrame; | ||
|
|
||
| class AssumeByrefFromJITStackFrame : public Frame | ||
| { | ||
| public: | ||
| #ifndef DACCESS_COMPILE | ||
| AssumeByrefFromJITStackFrame(OBJECTREF *pObjRef) : Frame(FrameIdentifier::AssumeByrefFromJITStackFrame) | ||
| { | ||
| m_pObjRef = pObjRef; | ||
| } | ||
| #endif | ||
|
|
||
| BOOL Protects_Impl(OBJECTREF *ppORef) | ||
| { | ||
| LIMITED_METHOD_CONTRACT; | ||
| return ppORef == m_pObjRef; | ||
| } | ||
|
|
||
| private: | ||
| OBJECTREF *m_pObjRef; | ||
| }; //AssumeByrefFromJITStackFrame | ||
|
|
||
| #endif //_DEBUG | ||
|
|
||
| //------------------------------------------------------------------------ | ||
| // These macros GC-protect OBJECTREF pointers on the EE's behalf. | ||
| // In between these macros, the GC can move but not discard the protected | ||
|
|
@@ -2919,25 +2889,22 @@ class AssumeByrefFromJITStackFrame : public Frame | |
| (OBJECTREF*)&(ObjRefStruct), \ | ||
| sizeof(ObjRefStruct)/sizeof(OBJECTREF), \ | ||
| FALSE); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GCPROTECT) | ||
| { | ||
|
|
||
| #define GCPROTECT_BEGIN_THREAD(pThread, ObjRefStruct) do { \ | ||
| GCFrame __gcframe( \ | ||
| pThread, \ | ||
| (OBJECTREF*)&(ObjRefStruct), \ | ||
| sizeof(ObjRefStruct)/sizeof(OBJECTREF), \ | ||
| FALSE); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GCPROTECT) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A note - I believe this removal is correct because we have changed the GCFrame to call Pop from the destructor couple of years ago. The requirement for no return was already obsolete. |
||
| { | ||
|
|
||
| #define GCPROTECT_ARRAY_BEGIN(ObjRefArray,cnt) do { \ | ||
| GCFrame __gcframe( \ | ||
| (OBJECTREF*)&(ObjRefArray), \ | ||
| cnt * sizeof(ObjRefArray) / sizeof(OBJECTREF), \ | ||
| FALSE); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GCPROTECT) | ||
| { | ||
|
|
||
| #define GCPROTECT_BEGININTERIOR(ObjRefStruct) do { \ | ||
| /* work around Wsizeof-pointer-div warning as we */ \ | ||
|
|
@@ -2947,20 +2914,18 @@ class AssumeByrefFromJITStackFrame : public Frame | |
| (OBJECTREF*)&(ObjRefStruct), \ | ||
| subjectSize/sizeof(OBJECTREF), \ | ||
| TRUE); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GCPROTECT) | ||
| { | ||
|
|
||
| #define GCPROTECT_BEGININTERIOR_ARRAY(ObjRefArray,cnt) do { \ | ||
| GCFrame __gcframe( \ | ||
| (OBJECTREF*)&(ObjRefArray), \ | ||
| cnt, \ | ||
| TRUE); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GCPROTECT) | ||
| { | ||
|
|
||
|
|
||
| #define GCPROTECT_END() \ | ||
| DEBUG_ASSURE_NO_RETURN_END(GCPROTECT) } \ | ||
| } \ | ||
| } while(0) | ||
|
|
||
|
|
||
|
|
@@ -2977,27 +2942,6 @@ class AssumeByrefFromJITStackFrame : public Frame | |
|
|
||
| #define ASSERT_ADDRESS_IN_STACK(address) _ASSERTE (Thread::IsAddressInCurrentStack (address)); | ||
|
|
||
| #if defined (_DEBUG) && !defined (DACCESS_COMPILE) | ||
| #define ASSUME_BYREF_FROM_JIT_STACK_BEGIN(__objRef) \ | ||
| /* make sure we are only called inside an FCall */ \ | ||
| if (__me == 0) {}; \ | ||
| /* make sure the address is in stack. If the address is an interior */ \ | ||
| /*pointer points to GC heap, the FCall still needs to protect it explicitly */ \ | ||
| ASSERT_ADDRESS_IN_STACK (__objRef); \ | ||
| do { \ | ||
| AssumeByrefFromJITStackFrame __dummyAssumeByrefFromJITStackFrame ((__objRef)); \ | ||
| __dummyAssumeByrefFromJITStackFrame.Push (); \ | ||
| /* work around unreachable code warning */ \ | ||
| if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GC_PROTECT) | ||
|
|
||
| #define ASSUME_BYREF_FROM_JIT_STACK_END() \ | ||
| DEBUG_ASSURE_NO_RETURN_END(GC_PROTECT) } \ | ||
| __dummyAssumeByrefFromJITStackFrame.Pop(); } while(0) | ||
| #else //defined (_DEBUG) && !defined (DACCESS_COMPILE) | ||
| #define ASSUME_BYREF_FROM_JIT_STACK_BEGIN(__objRef) | ||
| #define ASSUME_BYREF_FROM_JIT_STACK_END() | ||
| #endif //defined (_DEBUG) && !defined (DACCESS_COMPILE) | ||
|
|
||
| void ComputeCallRefMap(MethodDesc* pMD, | ||
| GCRefMapBuilder * pBuilder, | ||
| bool isDispatchCell); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it is still unsafe to
returnfrom within a CONTRACT block. However, I believe that it is quite obvious that it is incorrect to do so, to the point that it would immediately pop out in code-review as an issue that must be fixed (to the point that I would expect AI code review tools like Copilot to flag it as suspicious).