Skip to content

NetworkInterface.GetPhysicalAddress().GetAddressBytes() seems problematic with LLVM enabled on Android x86_64 #75155

@pjcollins

Description

@pjcollins

Description

We have a test in xamarin-android that compares network interface information obtained from mono vs java that is producing inconsistent results. When this test runs on an x86_64 emulator without AOT+LLVM enabled it passes, but when LLVM is enabled it fails. I have trimmed this down to a smaller repro project that I have attached. The problematic code appears to be as follows:

foreach (var inf in NetworkInterface.GetAllNetworkInterfaces ()) {
    byte[] bytes = inf.GetPhysicalAddress ().GetAddressBytes ();
    if (bytes.All (x => x == 0)) {
      // Condition is true for interfaces with physical addresses when LLVM is enabled, and false when LLVM is disabled
    }
}

Reproduction Steps

  1. Build xamarin-android/main, or install the workload packs produced by a recent build from CI.

  2. Download the DroidTestIface.zip repro project and run it on an x86_64 emulator:

dotnet build DroidTestIface.csproj -v:n -c Release -p:EnableLlvm=true -p:AndroidEnableProfiledAot=false
  1. After installation open the app on the emulator and tap the button.

Expected behavior

When building in debug without AOT/LLVM enabled, I see that a couple of network interfaces with physical addresses will return false when checking if their physical address bytes are all zero.

Actual behavior

When building with AOT/LLVM enabled, I see that the network interfaces that had physical addresses will return true when checking if their physical address bytes are all zero.

Regression?

No response

Known Workarounds

No response

Configuration

This issue is present when running on an an Android x86_64 emulator, using an Android SDK built against the following:

<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="7.0.100-rc.2.22426.5">
  <Uri>https://github.com/dotnet/installer</Uri>
  <Sha>2d1a4de6b2da59647a9538bf9cc4e252847e6231</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="7.0.0-rc.1.22422.12" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
  <Uri>https://github.com/dotnet/runtime</Uri>
  <Sha>ef077d0b58ffddcf54fa73bd85dace6b999b8992</Sha>
</Dependency>

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions