Skip to content

Commit 60f1105

Browse files
authored
[mono][jit] Fix clearing of LastError (#57127)
* [mono][jit] Fix clearing of LastError The clearing was added as part of CEE_CALL and CEE_CALLVIRT opcodes instead of CEE_CALLI which is actually used for pinvoke calls. * Disable test We can't enable this test on wasm due to dynamic library lookup limitation On android we seem to have some sort of issue with the runtime tests causing the pinvokes failing to be resolved
1 parent c8dc49e commit 60f1105

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/mono/mono/mini/method-to-ir.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7088,6 +7088,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
70887088
inst_tailcall && is_supported_tailcall (cfg, ip, method, NULL, fsig,
70897089
FALSE/*virtual irrelevant*/, addr != NULL, &tailcall);
70907090

7091+
if (save_last_error)
7092+
mono_emit_jit_icall (cfg, mono_marshal_clear_last_error, NULL);
7093+
70917094
if (callee) {
70927095
if (method->wrapper_type != MONO_WRAPPER_DELEGATE_INVOKE)
70937096
/* Not tested */
@@ -7589,10 +7592,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
75897592
}
75907593
}
75917594

7592-
if (save_last_error) {
7593-
mono_emit_jit_icall (cfg, mono_marshal_clear_last_error, NULL);
7594-
}
7595-
75967595
/* Tail prefix / tailcall optimization */
75977596

75987597
/* FIXME: Enabling TAILC breaks some inlining/stack trace/etc tests.

src/tests/issues.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,6 @@
12361236
<ExcludeList Include="$(XunitTestBinBase)/Interop/PInvoke/SafeHandles/**">
12371237
<Issue>https://github.com/dotnet/runtime/issues/48084</Issue>
12381238
</ExcludeList>
1239-
<ExcludeList Include="$(XunitTestBinBase)/Interop/PInvoke/SetLastError/**">
1240-
<Issue>https://github.com/dotnet/runtime/issues/51600</Issue>
1241-
</ExcludeList>
12421239
<ExcludeList Include="$(XunitTestBinBase)/Interop/PInvoke/SizeParamIndex/PInvoke/Invalid/InvalidParamIndex/**">
12431240
<Issue>needs triage</Issue>
12441241
</ExcludeList>
@@ -2426,6 +2423,9 @@
24262423
<ExcludeList Include = "$(XunitTestBinBase)/Interop/PInvoke/Primitives/Int/PInvokeIntTest/**">
24272424
<Issue>https://github.com/dotnet/runtime/issues/41519</Issue>
24282425
</ExcludeList>
2426+
<ExcludeList Include="$(XunitTestBinBase)/Interop/PInvoke/SetLastError/**">
2427+
<Issue>https://github.com/dotnet/runtime/issues/41519</Issue>
2428+
</ExcludeList>
24292429
<ExcludeList Include = "$(XunitTestBinBase)/Interop/SuppressGCTransition/SuppressGCTransitionTest/**">
24302430
<Issue>https://github.com/dotnet/runtime/issues/41519</Issue>
24312431
</ExcludeList>
@@ -2735,6 +2735,9 @@
27352735
<ExcludeList Include = "$(XunitTestBinBase)/Interop/PInvoke/Primitives/Pointer/NonBlittablePointer/**">
27362736
<Issue>needs triage</Issue>
27372737
</ExcludeList>
2738+
<ExcludeList Include = "$(XunitTestBinBase)/Interop/PInvoke/SetLastError/**">
2739+
<Issue>needs triage</Issue>
2740+
</ExcludeList>
27382741
<ExcludeList Include = "$(XunitTestBinBase)/Interop/SuppressGCTransition/SuppressGCTransitionTest/**">
27392742
<Issue>needs triage</Issue>
27402743
</ExcludeList>

0 commit comments

Comments
 (0)