Unverified Commit e7984bd4 authored by Dan Field's avatar Dan Field Committed by GitHub

Handle StackOverflows (#49629)

parent f2865090
......@@ -59,6 +59,18 @@ class StackFrame {
source: '<asynchronous suspension>',
);
/// A stack frame representing a Dart elided stack overflow frame.
static const StackFrame stackOverFlowElision = StackFrame(
number: -1,
column: -1,
line: -1,
method: '...',
packageScheme: '',
package: '',
packagePath: '',
source: '...',
);
/// Parses a list of [StackFrame]s from a [StackTrace] object.
///
/// This is normally useful with [StackTrace.current].
......@@ -113,6 +125,8 @@ class StackFrame {
assert(line != null);
if (line == '<asynchronous suspension>') {
return asynchronousSuspension;
} else if (line == '...') {
return stackOverFlowElision;
}
// Web frames.
......
......@@ -47,6 +47,28 @@ void main() {
webStackTraceFrames,
);
});
test('Parses ...', () {
expect(
StackFrame.fromStackTraceLine('...'),
StackFrame.stackOverFlowElision,
);
});
test('Live handling of Stack Overflows', () {
void overflow(int seed) {
overflow(seed + 1);
}
bool overflowed = false;
try {
overflow(1);
} on StackOverflowError catch (e, stack) {
overflowed = true;
final List<StackFrame> frames = StackFrame.fromStackTrace(stack);
expect(frames.contains(StackFrame.stackOverFlowElision), true);
}
expect(overflowed, true);
}, skip: isBrowser);
}
const String stackString = '''#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment