[ci-fix] Needs review: Marshal mono_ios_* string args as UTF-8 for NativeAOT ILC (refs #130219)#130232
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
…lity The Apple test harness p/invokes mono_ios_append_output/mono_ios_set_summary declared 'string value' with default (ANSI) DllImport marshalling. The ILC NativeAOT compiler rejects this with MarshalDirectiveException, breaking every work item on the tvos-arm64/ios AllSubsets_NativeAOT legs enabled by #125437. The native implementations take 'const char*' and call [NSString stringWithUTF8String:], so UTF-8 (LPUTF8Str) marshalling is the correct, ILC-supported directive. Refs #130219 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Member
|
/azp run runtime-extra-platforms |
Member
|
I would be surprised if this fixes anything. Without this annotation, it should marshal as an ansi string, not throw this exception. This exception is very unexpected. |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Jul 6, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workflow artifact: ci-fix
Artifact kind: help
Linked KBE: #130219
Note
AI/Copilot-generated best-effort fix. The root cause and change below are well-supported by the native contract, but I could not run the ILC/NativeAOT tvOS cross-compile in this environment to confirm the compiler error is gone. Please have a mobile/interop owner validate before merging.
Root cause
Every work item on the
tvos-arm64 Release AllSubsets_NativeAOTleg (and the other Apple NativeAOT library-test legs enabled by #125437) aborts on startup:The harness declares the UI-callback p/invokes with default
DllImportstring marshalling:Default
DllImportstring marshalling isCharSet.Ansi. Under Mono AOT this was tolerated, but the ILC (NativeAOT) compiler rejects it here withMarshalDirectiveException. Native symbol resolution itself is fine — #125437 wiresDirectPInvoke __Internalsomono_ios_set_summaryresolves statically — the failure is purely the marshalling directive, so the process fails before the first test runs.Attempted fix
Annotate both
stringparameters with[MarshalAs(UnmanagedType.LPUTF8Str)]. This is not an arbitrary choice: the native implementations insrc/tasks/AppleAppBuilder/Templates/main-console.mtakeconst char*and immediately call[NSString stringWithUTF8String:value], i.e. they expect a UTF-8 C string. SoLPUTF8Str:These are test-harness display hooks (they update the on-device summary/output UI); no test logic or assertion is changed, and nothing is skipped or disabled.
What is unverified / where I need help
MarshalDirectiveExceptionis eliminated. Please confirm thatLPUTF8Stron aDirectPInvoke __Internalimport compiles under ILC for these legs.[LibraryImport]marshalling for NativeAOT correctness, that is a reasonable alternative — this PR takes the minimal directive-only approach.Validation
AppleTestRunner— not run because the Apple NativeAOT toolchain and cross-compile exceed this environment's capabilities/time budget.UnmanagedType.LPUTF8StrandSystem.Runtime.InteropServicesare already in scope in the file.Evidence
mono_ios_set_summaryviaDirectPInvoke __Internal— high confidence this is the surfacing change.src/tasks/AppleAppBuilder/Templates/main-console.mlines ~107-121 (const char*+stringWithUTF8String).Help wanted
@kotlarmilos([mobile] Enable NativeAOT library tests on Apple mobile platforms #125437)@jkoritzinsky,@dotnet/ilc-contribSuggested reviewers / area contacts
area-NativeAOT-coreclr:@agocke,@dotnet/ilc-contribos-ios):@kotlarmilos,@steveisokFiled by
ci-failure-fix. Comment here or on the workflow file to suggest changes;ci-failure-scan-feedbackreads in-scope feedback daily and opens (or updates) a PR with prompt edits.Note
🔒 Integrity filter blocked 6 items
The following items were blocked because they don't meet the GitHub integrity level.
search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: