Repository navigation
Conversation
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
Fixes the Apple CFNumberGetValue ABI mismatch that can crash CoreCLR’s interpreter when resolving proxies.
Changes:
- Passes
CFNumberTypeas pointer-sizedCFIndex. - Adds injectable proxy settings for deterministic testing.
- Replaces the fake proxy with real Apple interop tests.
| File | Description |
|---|---|
| src/libraries/System.Net.Http/tests/UnitTests/System.Net.Http.Unit.Tests.csproj | Updated as part of this pull request. |
| src/libraries/System.Net.Http/tests/UnitTests/MacProxyTest.cs | Updated as part of this pull request. |
| src/libraries/System.Net.Http/tests/UnitTests/Fakes/MacProxy.cs | Updated as part of this pull request. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/MacProxy.cs | Updated as part of this pull request. |
| src/libraries/Common/src/Interop/OSX/Interop.CoreFoundation.CFNumber.cs | Updated as part of this pull request. |
Author
|
Closing in favor of #135089 |
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.
Fixes #134617
On iOS with CoreCLR,
MacProxycrashes withEXC_BAD_ACCESSinCFNumberGetValuewhen the system proxy configuration returns an HTTP/HTTPS proxy, whether from a PAC script or a manual setting.SocketsHttpHandlergoes through this path whenever it consultsHttpClient.DefaultProxy. This was discovered while moving from .NET 10 to .NET 11 and testing with Browserstack (see issue for details).Cause
CFNumberTypeis declared asCF_ENUM(CFIndex, CFNumberType), so it's 64-bit. The P/Invoke inInterop.CoreFoundation.CFNumber.cspasses it as an int-sized enum, which leaves the upper 32 bits ofx1unspecified.CFNumberGetValueuses the whole register as an index into its type table (ldrh w9, [x9, x20, lsl #1]), so it reads far out of bounds.Changes
Interop.CoreFoundation.CFNumber.cs: the P/Invoke now takesCFIndex. A wrapper keeps the typed enum for callers.MacProxy.cs:GetProxy(Uri)now calls a new internalGetProxy(Uri, SafeCFDictionaryHandle)overload that takes the proxy settings, so tests can supply their own. Behavior is unchanged.System.Net.Http.Unit.Tests: on Apple targets, the project now compiles the realMacProxyand its interop instead of the fake, and addsMacProxyTest.CFNetworkCopySystemProxySettingsreturns, so they don't depend on the machine's proxy configuration.Testing
Please note, this does removes the existing
Fakes/MacProxy.csfile as we need to use the real one for testing. I'm unsure if this is the best approach, but it got me to first replicate the failure I was encountering on an actual device.The new tests can only fail where this code runs on the interpreter. Results on the iOS simulator with the 11.0 RC1 CoreCLR runtime pack:
GetProxy_HttpProxy_ReturnsProxyUriGetProxy_ProxyAutoConfigurationScript_ReturnsProxyUriGetProxy_ProxyAutoConfigurationScriptReturnsDirect_ReturnsNullGetProxy_NoProxy_ReturnsNullGetProxy_ProxyAutoConfigurationScriptReturnsDirect_ReturnsNullgoes through the same PAC callback without reading a port, which shows the callback isn't the problem.Other runs, all against the 11.0 RC1 runtime using this branch's
System.Net.Httpand test builds:System.Net.Http.Unit.Tests, full suite: passes on macOS and on the iOS simulator (interpreter).System.Net.Http.Functional.Tests, full inner-loop suite: passes on macOS, with results identical to the unfixed build.