dotnet / dotnet/runtime

nativeaot for rtos

Open
#119,856 81 comments 1 reaction 0 assignees View on GitHub
arch-arm32 area-NativeAOT-coreclr question
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

I am now continuing to work on the porting of nativeaot+rtos:

I'm encountering an infinite loop in the stack unwinding logic when calling Environment.StackTrace in a minimal C# program. After resolving TLS-related issues (--enable-tls confirmed working), the stack frame iterator enters an infinite loop during stack unwinding.
```
main()
{
var stacktrace = Environment.StackTrace;
}
```
Observed Behavior:​​
The call stack enters an infinite loop in StackFrameIterator::Next() because IsValid() persistently returns true. When examining the ControlPC values during unwinding, I observe the following pattern:
```
1.S_P_CoreLib_System_Runtime_RuntimeExports__RhGetCurrentThreadStackTrace
2.S_P_CoreLib_System_Diagnostics_StackTrace__InitializeForCurrentThread
3.S_P_CoreLib_System_Diagnostics_StackTrace___ctor_0
4.S_P_CoreLib_System_Environment__get_StackTrace
5.Helloworld_Helloworld_Program__Main
6.__managed__Main
7.__managed__Main (repeated)
8.__managed__Main (repeated)
```
Problem Location:​​
The infinite loop occurs in RhpCalculateStackTraceWorker():
```
RhpCalculateStackTraceWorker()
{
while (frameIter.Next()){ ....}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.