What determines the (default) depth of an exception stacktrace?

Viewed 70

Assuming the current call stack is rather deep.

Is there a limit to the depth of an exception stacktrace? Or is it 1:1 the depth of the call stack? If so, what other reasons could there be that the stacktrace "ends early"?

EDIT: See also this other question which provides the concrete context that sparked this one.

EDIT2: Experimentation seems to indicate that the depth is not normally limited. See https://dotnetfiddle.net/2YTKui

1 Answers

Ok, it seems that the entire thing was a misconception on my part.

The StackTrace per se seems to be quasi infinite.

But an exception stacktrace only ever captures the stackframes between the position where the exception occurs and the position where it is caught/handled.

Related