Skip to content

nativeaot for rtos #119856

@snikeguo

Description

@snikeguo

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()){ ....}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-arm32area-NativeAOT-coreclrquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions