Commit 288de11
authored
[Mono]: Fix static closed delegate fnptr crash. (#68701)
* Fix static closed delegate fnptr crash.
When accessing a function pointer to a static closed delegate like
done in added test:
GetFunctionPointerForDelegate_MarshalledClosedStaticDelegate
it will trigger a read outside of the allocated mspecs buffer since
invoke_sig and method signature arguments wont match.
There was already logic to adjust this in emit_managed_wrapper_ilgen,
but done after call to emit_managed_wrapper_validate_signature
that will touch memory and depending on its content, trigger a crash.
Fix make sure we do signature adjustments first and then validate
the signature. Fix also adjust a couple of mspecs allocations to use
g_new0 as all others to make sure we get NULL pointers in the mspecs
array.
Since this scenario was not covered on CI, commit also adds a new test
in GetFunctionPointerForDelegateTests.cs covering this scenario.1 parent c9d8f80 commit 288de11
File tree
4 files changed
+39
-15
lines changed- src
- libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal
- mono/mono/metadata
4 files changed
+39
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
95 | 115 | | |
96 | 116 | | |
| 117 | + | |
97 | 118 | | |
98 | 119 | | |
99 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2089 | 2089 | | |
2090 | 2090 | | |
2091 | 2091 | | |
2092 | | - | |
| 2092 | + | |
2093 | 2093 | | |
2094 | 2094 | | |
2095 | 2095 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
| 746 | + | |
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| |||
5023 | 5023 | | |
5024 | 5024 | | |
5025 | 5025 | | |
5026 | | - | |
| 5026 | + | |
5027 | 5027 | | |
5028 | 5028 | | |
5029 | 5029 | | |
| |||
5067 | 5067 | | |
5068 | 5068 | | |
5069 | 5069 | | |
5070 | | - | |
| 5070 | + | |
| 5071 | + | |
| 5072 | + | |
| 5073 | + | |
| 5074 | + | |
| 5075 | + | |
| 5076 | + | |
| 5077 | + | |
| 5078 | + | |
| 5079 | + | |
| 5080 | + | |
| 5081 | + | |
| 5082 | + | |
5071 | 5083 | | |
| 5084 | + | |
5072 | 5085 | | |
5073 | 5086 | | |
5074 | 5087 | | |
| |||
5079 | 5092 | | |
5080 | 5093 | | |
5081 | 5094 | | |
5082 | | - | |
5083 | | - | |
5084 | | - | |
5085 | | - | |
5086 | | - | |
5087 | | - | |
5088 | | - | |
5089 | | - | |
5090 | | - | |
5091 | | - | |
5092 | 5095 | | |
5093 | 5096 | | |
5094 | 5097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3561 | 3561 | | |
3562 | 3562 | | |
3563 | 3563 | | |
3564 | | - | |
| 3564 | + | |
3565 | 3565 | | |
3566 | 3566 | | |
3567 | 3567 | | |
| |||
0 commit comments