Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergely Kalapos <gergo@kalapos.net>2017-05-18 02:35:06 +0300
committerJan Kotas <jkotas@microsoft.com>2017-05-18 02:35:06 +0300
commit0166403cf2d2cb8eb4f75084a520afbb0fd822ff (patch)
treee5efe142a8435c1e32bd951ea5332226079307b3
parentff16b57f70d5b032d1d819cb460226b5db454f03 (diff)
Verification of Endfinally (also Endfault) (#3640)
-rw-r--r--src/Common/src/TypeSystem/IL/ILImporter.cs2
-rw-r--r--src/ILVerify/src/ILImporter.Verify.cs31
-rw-r--r--src/ILVerify/src/Resources/Strings.resx3
-rw-r--r--src/ILVerify/src/VerifierError.cs2
4 files changed, 15 insertions, 23 deletions
diff --git a/src/Common/src/TypeSystem/IL/ILImporter.cs b/src/Common/src/TypeSystem/IL/ILImporter.cs
index 30111458c..46491a71b 100644
--- a/src/Common/src/TypeSystem/IL/ILImporter.cs
+++ b/src/Common/src/TypeSystem/IL/ILImporter.cs
@@ -777,7 +777,7 @@ namespace Internal.IL
case ILOpcode.sub_ovf_un:
ImportBinaryOperation(opCode);
break;
- case ILOpcode.endfinally:
+ case ILOpcode.endfinally: //both endfinally and endfault
ImportEndFinally();
return;
case ILOpcode.leave:
diff --git a/src/ILVerify/src/ILImporter.Verify.cs b/src/ILVerify/src/ILImporter.Verify.cs
index ad7a43c14..ca3e29055 100644
--- a/src/ILVerify/src/ILImporter.Verify.cs
+++ b/src/ILVerify/src/ILImporter.Verify.cs
@@ -98,6 +98,8 @@ namespace Internal.IL
public int? FilterIndex;
};
+ void EmptyTheStack() => _stackTop = 0;
+
void Push(StackValue value)
{
FatalCheck(_stackTop < _maxStack, VerifierError.StackOverflow);
@@ -500,9 +502,8 @@ namespace Internal.IL
if (r.ILRegion.Kind == ILExceptionRegionKind.Filter)
MarkBasicBlock(_basicBlocks[r.ILRegion.FilterOffset]);
-
- if (r.ILRegion.Kind == ILExceptionRegionKind.Filter || r.ILRegion.Kind == ILExceptionRegionKind.Catch)
- MarkBasicBlock(_basicBlocks[r.ILRegion.HandlerOffset]);
+
+ MarkBasicBlock(_basicBlocks[r.ILRegion.HandlerOffset]);
}
}
@@ -1345,31 +1346,19 @@ namespace Internal.IL
void ImportLeave(BasicBlock target)
{
- // Empty the stack
- _stackTop = 0;
-
-#if false
- for (int i = 0; i < _exceptionRegions.Length; i++)
- {
- var r = _exceptionRegions[i];
-
- if (r.ILRegion.Kind == ILExceptionRegionKind.Finally &&
- IsOffsetContained(_currentOffset - 1, r.ILRegion.TryOffset, r.ILRegion.TryLength) &&
- !IsOffsetContained(target.StartOffset, r.ILRegion.TryOffset, r.ILRegion.TryLength))
- {
- MarkBasicBlock(_basicBlocks[r.ILRegion.HandlerOffset]);
- }
- }
-#endif
+ EmptyTheStack();
MarkBasicBlock(target);
-
// TODO
}
void ImportEndFinally()
{
- // TODO
+ Check(_currentBasicBlock.HandlerIndex.HasValue, VerifierError.Endfinally);
+ Check(_exceptionRegions[_currentBasicBlock.HandlerIndex.Value].ILRegion.Kind == ILExceptionRegionKind.Finally ||
+ _exceptionRegions[_currentBasicBlock.HandlerIndex.Value].ILRegion.Kind == ILExceptionRegionKind.Fault, VerifierError.Endfinally);
+
+ EmptyTheStack();
}
void ImportNewArray(int token)
diff --git a/src/ILVerify/src/Resources/Strings.resx b/src/ILVerify/src/Resources/Strings.resx
index 76b717caa..eba02b4c2 100644
--- a/src/ILVerify/src/Resources/Strings.resx
+++ b/src/ILVerify/src/Resources/Strings.resx
@@ -141,6 +141,9 @@
<data name="EndfilterStack" xml:space="preserve">
<value>Stack not empty when leaving an exception filter.</value>
</data>
+ <data name="Endfinally" xml:space="preserve">
+ <value>Endfinally from outside a finally handler.</value>
+ </data>
<data name="ExpectedArray" xml:space="preserve">
<value>Expected single-dimension zero-based array.</value>
</data>
diff --git a/src/ILVerify/src/VerifierError.cs b/src/ILVerify/src/VerifierError.cs
index 37524b6f3..2714ca805 100644
--- a/src/ILVerify/src/VerifierError.cs
+++ b/src/ILVerify/src/VerifierError.cs
@@ -60,7 +60,7 @@ namespace ILVerify
//E_FALLTHRU_INTO_FIL "fallthru into an exception filter."
//E_LEAVE "Leave from outside a try or catch block."
Rethrow, //"Rethrow from outside a catch handler."
- //E_ENDFINALLY "Endfinally from outside a finally handler."
+ Endfinally, //"Endfinally from outside a finally handler."
Endfilter, //"Endfilter from outside an exception filter block."
//E_ENDFILTER_MISSING "Missing Endfilter."
//E_BR_INTO_TRY "Branch into try block."