Skip to content
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

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

Closed
pjcollins opened this issue Sep 6, 2022 · 9 comments

Comments

@pjcollins
Copy link
Member

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

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 6, 2022
@ghost
Copy link

ghost commented Sep 7, 2022

Tagging subscribers to 'arch-android': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: pjcollins
Assignees: -
Labels:

os-android, untriaged

Milestone: -

@ghost
Copy link

ghost commented Sep 7, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: pjcollins
Assignees: -
Labels:

area-System.Net, os-android, untriaged

Milestone: -

@akoeplinger
Copy link
Member

/cc @vargaz @lambdageek

Not sure if this should be a 7.0 or 8.0 issue.

@marek-safar
Copy link
Contributor

I think this is worth backporting either way.

@SamMonoRT could you assign this?

@SamMonoRT
Copy link
Member

@vargaz can you take a look?

@SamMonoRT SamMonoRT removed the untriaged New issue has not been triaged by the area owner label Sep 8, 2022
@vargaz
Copy link
Contributor

vargaz commented Sep 8, 2022

Probably fixed by:
#74991
which is not in rc2

jonathanpeppers pushed a commit to dotnet/android that referenced this issue Sep 8, 2022
It appears that an Android NDK installation is no longer needed when
using Aot with LLVM.  Projects which enable Aot and LLVM will no longer
attempt to use the NDK unless it is explicitly requested by setting
`$(AndroidNdkDirectory)` to a valid NDK path in the project file.

This also enables tests for LLVM with a few categories turned off for now:

* `InetAccess`: dotnet/runtime#73304
* `NetworkInterfaces`: dotnet/runtime#75155
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 15, 2022
Context: dotnet/runtime#73304
Context: dotnet/runtime#75155

The issues for these should be fixed in .NET 7 RC 2.
@steveisok steveisok added this to the 8.0.0 milestone Sep 21, 2022
@steveisok
Copy link
Member

Probably fixed by: #74991 which is not in rc2

@vargaz this should be in RC2 at least according to the date the PR was merged. Is this good to close?

@vargaz
Copy link
Contributor

vargaz commented Sep 21, 2022

It is actually in rc2, can somebody check whenever it works now ?

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 28, 2022
Context: dotnet/runtime#73304
Context: dotnet/runtime#75155

The issues for these should be fixed in .NET 7 RC 2.
jonathanpeppers added a commit to dotnet/android that referenced this issue Sep 30, 2022
Context: dotnet/runtime#73304
Context: dotnet/runtime#75155

The issues for these should be fixed in .NET 7 RC 2.
jonathanpeppers added a commit to dotnet/android that referenced this issue Sep 30, 2022
Context: dotnet/runtime#73304
Context: dotnet/runtime#75155

The issues for these should be fixed in .NET 7 RC 2.
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants