Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

NullReferenceException in AndroidRidAbiHelper.GetNativeLibraryAbi for rooted paths

Aperta
#13,063 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@AustinAviv ci sta già lavorando.

Dal 10/10/2026.

  • #13064 di @AustinAviv — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
C#
Stelle
2.1k
Fork
579
Merge medio
2g 5h
PR unite (30g)
213

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/android

Tutte le issue di dotnet/android

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.