Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

NullReferenceException in AndroidRidAbiHelper.GetNativeLibraryAbi for rooted paths

Đã đóng
#13,063 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@AustinAviv đang làm issue này rồi.

Từ ngày 10/10/2026.

  • #13064 của @AustinAviv — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
build-system, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
C#
Star
2.1k
Fork
581
Merge trung bình
2 ngày 6 phút
Pull request đã merge (30 ngày)
245

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/android

Tất cả issue của dotnet/android

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.