dotnet / dotnet/android

Native tombstone backtrace truncated to 2 frames when Helpers::abort_application is called from pinvoke override path.

Open
#11,535 3 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

### Android framework version

net11.0-android (Preview)

### Affected platform version

.NET11.0 Preview4

### Description

When a P/Invoke resolution fails in the precompiled pinvoke override path (e.g., missing symbol in `libSystem.Native`), the native tombstone only shows 2 frames:

```
#00 pc ... libc.so (abort+160)
#1 pc ... libmonodroid.so (Helpers::abort_application+584)
```

The caller chain `PinvokeOverride::monodroid_pinvoke_override` and the CoreCLR frames that invoked it (`PInvokeOverride::GetMethodImpl`, `PInvokeLink`) is missing from the tombstone, making it harder to diagnose the failure path from the native side alone.

The managed callstack logged via the DOTNET logcat tag is correct and useful, but the native tombstone is incomplete.

Expected: The tombstone should include native frames above` Helpers::abort_application` showing the call path through the pinvoke override.

Possible contributing factors:

- [[gnu::flatten]] on `monodroid_pinvoke_override` may affect frame layout.
- Interaction between [[noreturn]] on `Helpers::abort_application` and optimizer decisions.
- Build flags (LTO, frame pointer settings) affecting unwind info completeness.

### Steps to Reproduce

An app referencing a P/Invoke in libSystem.Native that is not present in the precompiled pinvoke tables (triggers the "Missing pinvoke" abort path). This issue triggers this scenario, https://github.com/dotnet/android/issues/11530. That issue also carries the repro and the tombstone triggered by a missing pinvoke symbol in pinvoke overrides.

### Did you find any workaround?

_No response_

### Relevant log output

```shell

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.