NullReferenceException in AndroidRidAbiHelper.GetNativeLibraryAbi for rooted paths
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp
- 领域
- build-system, mobile
调研方向
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 内容生成。
描述
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
- 平均合并
- 2 天 6 分钟
- 30 天内合并 PR
- 245
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/android 的其他 Issue
-
Area: App+Library Build
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Area: Mono.Android
难度 2/5 1-3 小时 新手友好度 65/100
dotnet/android#9192 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
.NET 11 RC2 MAUI app fails to compile (NativeAOT) with MAUI Community Toolkit可能已有人在做 @simonrozsival 今天认领。 未关闭Area: App+Library Build needs-triage
难度 4/5 3-5 天 新手友好度 15/100
dotnet/android#13143 · 1 条评论 ·
维护者通常 1 天内回复
-
needs-triage
难度 3/5 半天 新手友好度 45/100
dotnet/android#13142 · 1 条评论 ·
维护者通常 1 天内回复
-
needs-triage
难度 4/5 一周以上 新手友好度 18/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
ClickHouse/clickhouse-cs#689 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 7 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
vchelaru/FlatRedBall2#1481 ·
维护者通常 1 天内回复
-
ai-chat bug trivial
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
area-signalr
难度 2/5 1-3 小时 新手友好度 75/100
dotnet/aspnetcore#69842 · 1 条评论 ·
维护者通常 1 天内回复