-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Encode calling convention in mangled function pointer representation #81122
Conversation
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
var fnPtrType = (FunctionPointerType)type; | ||
mangledName = "__FnPtr" + EnterNameScopeSequence; | ||
mangledName = "__FnPtr_" + ((int)fnPtrType.Signature.Flags).ToString("X2") + EnterNameScopeSequence; |
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.
@steveharter what was the decision about function pointer type identity within the runtime? Do we only consider the value of the legacy "calling convention flags" or do we also include calling conventions from modopts, or do we consider all modopts everywhere in the signature?
(I admit I dropped the ball on following the discussion. I'll need to read up on it to actually implement this in nativeaot but can't spend time on it right now.)
This fix looks good if we only consider the legacy calling convention flags.
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.
Are runtime tests running with NativeAOT? It seems that there is a gap in NativeAOT as well. I don't recall seeing the function pointer tests failing for NativeAOT.
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.
@fanyang-mono I defer to Michal to elaborate in more detail, according to the running times and the logs I'm seeing for the NativeAOT legs in the runtime (PR / CI) pipeline I'm guessing that right now just a small subset of Pri0 tests gets run on a regular basis in NativeAOT mode.
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.
This codepath is only exercised in obscure cases in NativeAOT - #71749. Most of the time function pointers are treated as IntPtr right now. It will have to change for .NET 8.
And yes, we don't run regular Pri0/Pri1 CoreCLR test suite runs right now. Another thing getting addressed for 8.0.
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.
Gotcha!
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.
@steveharter what was the decision about function pointer type identity within the runtime?
@steveharter is on vacation.
In current main, the function pointer runtime type identity includes calling convention from signature. Modopts are not included in the function pointer runtime type identity.
After #81006, the function pointer runtime type identity is only going to include managed vs. unmanaged. The full calling convention details and modopts are not going to be part of function pointer runtime type identity.
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.
Thanks Jan and Michal for your feedback. I have deleted the superfluous comment per Michal's suggestion in the 2nd commit.
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@steveharter - could you please respond to @MichalStrehovsky's question when you have a chance? We're trying to stay on top of customer bug escalations and I'm having an active Teams thread with Mono folks who need the fix getting backported to .NET 7 so I'm trying to figure out how to make it at least to main. |
This fixes the recently introduced issue dotnet#81106 tracking Crossgen2 crash due to not being able to distinguish two function pointers differing only by calling convention (one of the pointers is Static and the other is Static | UnmanagedCallingConvention). Thanks Tomas
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp runtime-coreclr outerloop |
Command 'runtime-coreclr' is not supported by Azure Pipelines. Supported commands
See additional documentation. |
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
The one failure in the DictionaryExpansion test on Windows x86 is known, I'll probably take the bug as it's currently assigned to @davidwrighton who's expected to be OOF for a prolonged period of time. I'm going to merge this in assuming no other untracked issues pop up in the remaining outerloop jobs. |
OK, there's one more bug but that's also known, #81109, I'm actually investigating it right now, that's obviously unrelated to this change, merging in. |
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/4058243565 |
@trylek backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Encode calling convention in mangled function pointer representation
Applying: Delete superfluous comment per Michal's PR feedback
Applying: Remove issues.targets exclusion for the function pointer test
Using index info to reconstruct a base tree...
M src/tests/issues.targets
Falling back to patching base and 3-way merge...
Auto-merging src/tests/issues.targets
CONFLICT (content): Merge conflict in src/tests/issues.targets
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0003 Remove issues.targets exclusion for the function pointer test
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@trylek an error occurred while backporting to release/7.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
* Fix function pointer check * Make is_monomorphic_array return false when the element is function pointer * Move test to a better location * Disable function pointer test for crossgen due to an existing issue * Backport of PR #81122 to .NET 7.0, revert change to issues.targets Based on tactical discussion with Fan and Sam I have backported the PR #81122 including the removal of the issues.targets entry for function pointer tests as an extra commit on top of the backport of Fan's PR #80855. Thanks Tomas --------- Co-authored-by: Fan Yang <yangfan@microsoft.com> Co-authored-by: Fan Yang <52458914+fanyang-mono@users.noreply.github.com> Co-authored-by: Tomas <trylek@microsoft.com>
This fixes the recently introduced issue #81106 tracking Crossgen2 crash due to not being able to distinguish two function pointers differing only by calling convention (one of the pointers is Static and the other is Static | UnmanagedCallingConvention).
Thanks
Tomas
Fixes: #81106
/cc @dotnet/crossgen-contrib