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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThays Grazia <thaystg@gmail.com>2019-01-15 12:51:16 +0300
committerGitHub <noreply@github.com>2019-01-15 12:51:16 +0300
commit41eb90253553414ee530e93814ea8d32eecbf052 (patch)
tree45f18983cf3ff552a7890bf8c2ea85949cffdb93 /mcs/class/Mono.Debugger.Soft
parent3e3a2f51dd4a994d6db0ec1e2edcace40ed75f82 (diff)
[Debugger] Debugger failure when field content is assigned by an unsafe value (#12394)
* [Debugger] Debugger failure when a method is called in watches and any field of the Class has the type of the field different of the value of the field because the assign was done in an unsafe way like this: Now the datatypes check in the fields are only executed when it's not inside an invoke method. _pinnable = Unsafe.As<Pinnable<T>>(array); A unit test that reproduces the issue was created either. Fixes #12374
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft')
-rw-r--r--mcs/class/Mono.Debugger.Soft/Makefile2
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs23
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest.cs21
3 files changed, 45 insertions, 1 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Makefile b/mcs/class/Mono.Debugger.Soft/Makefile
index f5b60492049..b1dda8bcb5f 100644
--- a/mcs/class/Mono.Debugger.Soft/Makefile
+++ b/mcs/class/Mono.Debugger.Soft/Makefile
@@ -34,7 +34,7 @@ $(test_output_dir)/dtest-excfilter.exe: Test/dtest-excfilter.il | $(test_output_
$(ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il
$(test_output_dir)/dtest-app.exe: Test/dtest-app.cs $(TEST_HELPERS_SOURCES) | $(test_output_dir)
- $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -sourcelink:Test/sourcelink.json -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
+ $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Runtime.CompilerServices.Unsafe.dll -sourcelink:Test/sourcelink.json -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
TEST_HELPERS_SOURCES = \
../test-helpers/NetworkHelpers.cs \
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
index b6ea142262a..031080caff3 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
@@ -193,6 +193,19 @@ public class GClass<T> {
}
}
+public struct MySpan<T> {
+ internal class Pinnable<J> {
+ public J Data;
+ }
+ Pinnable<T> _pinnable;
+ public MySpan(T[] array) {
+ _pinnable = Unsafe.As<Pinnable<T>>(array);
+ }
+ public override string ToString() {
+ return "abc";
+ }
+}
+
public struct GStruct<T> {
public T i;
@@ -474,6 +487,7 @@ public class Tests : TestsBase, ITest2
new Tests ().evaluate_method ();
Bug59649 ();
elapsed_time();
+ field_with_unsafe_cast_value();
inspect_enumerator_in_generic_struct();
return 3;
}
@@ -658,6 +672,15 @@ public class Tests : TestsBase, ITest2
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static void field_with_unsafe_cast_value() {
+ var arr = new char[3];
+ arr[0] = 'a';
+ arr[1] = 'b';
+ arr[2] = 'c';
+ MySpan<char> bytes = new MySpan<char>(arr);
+ }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void ss_nested () {
ss_nested_1 (ss_nested_2 ());
ss_nested_1 (ss_nested_2 ());
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
index 0ef677e0e07..e97dd8f3400 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
@@ -4807,5 +4807,26 @@ public class DebuggerTests
AssertValue (1, mirror["i"]);
AssertValue (2.0, mirror["d"]);
}
+
+ [Test]
+ public void FieldWithUnsafeCastValue() {
+ Event e = run_until("field_with_unsafe_cast_value");
+ var req = create_step(e);
+ req.Enable();
+ e = step_once();
+ e = step_over();
+ e = step_over();
+ e = step_over();
+ e = step_over();
+ e = step_over();
+ var frame = e.Thread.GetFrames () [0];
+ var ginst = frame.Method.GetLocal ("bytes");
+ Value variable = frame.GetValue (ginst);
+ StructMirror thisObj = (StructMirror)variable;
+ TypeMirror thisType = thisObj.Type;
+ variable = thisObj.InvokeMethod(e.Thread, thisType.GetMethod("ToString"), null);
+ AssertValue ("abc", variable);
+
+ }
} // class DebuggerTests
} // namespace