Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

NullReferenceException in AndroidRidAbiHelper.GetNativeLibraryAbi for rooted paths

クローズ
#13,063 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@AustinAviv がすでに取り組んでいます。

2026年10月10日 から。

  • #13064 @AustinAviv による — オープン

評価

難易度
2/5
見積もり時間
1時間未満
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp

調査の方向性

The bug is in GetNativeLibraryAbi in src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs, around line 43, where dir.Parent and dir.Name are dereferenced without null checks for rooted paths. Read the method's fallback path that inspects the parent directory for android-<abi>/native layouts. Done means a rooted path such as C:\libfoo.so or /libfoo.so returns null instead of throwing. Pull request #13064 already targets this, so review it before starting.

索引モデルが issue の本文から書いたものです。

説明

needs-triage
Android framework version

net10.0-android

Affected platform version

.NET 10 / main branch

Description

AndroidRidAbiHelper.GetNativeLibraryAbi throws an unhandled NullReferenceException when a native library path is located directly under a drive root or filesystem root (such as C:\libfoo.so on Windows or /libfoo.so on Linux).

In AndroidRidAbiHelper.GetNativeLibraryAbi (string lib):

var dir = Directory.GetParent (lib);
...
abi = RuntimeIdentifierToAbi (dir.Parent.Name.ToLowerInvariant ());

When lib is directly at the root, Directory.GetParent(lib) returns the root directory (for example C:\), whose .Parent property is null. When dirName does not match a known ABI name, the method checks the parent directory to detect RIDs like android-arm64/native, but dereferences dir.Parent.Name without checking if dir.Parent is null. Additionally, if lib is a root path directly (like / or C:\), Directory.GetParent(lib) returns null directly, causing dir.Name to throw.

Steps to Reproduce

Call AndroidRidAbiHelper.GetNativeLibraryAbi(@"C:\libfoo.so") or pass a TaskItem whose ItemSpec or Link is a rooted path without an intermediate directory.

AndroidRidAbiHelper.GetNativeLibraryAbi(@"C:\libfoo.so");

Observed result:
Throws System.NullReferenceException: Object reference not set to an instance of an object. at line 43.

Expected result:
Returns null without throwing an exception.

Relevant log output
System.NullReferenceException : Object reference not set to an instance of an object.
   at Microsoft.Android.Build.Tasks.AndroidRidAbiHelper.GetNativeLibraryAbi(String lib) in src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs:line 43
主要言語
C#
スター
2.1k
フォーク
581
平均マージ
1日 23時間
マージ済み PR(30日)
243

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/android のほかの issue

dotnet/android の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。