android / android/android-test

Tests failing with StackOverflowError cause a secondary OOM in TestExecutor

Open
#285 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

### Steps to Reproduce

```java
@Test
public void testWithInfiniteRecursion() {
recurseInfinitely();
}
```

### Expected Results

Test runner reports the StackOverflowError.

### Actual Results

Test runner crashes, because it tries to write the entire stacktrace to the summary writer:

```
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. Check device logcat for details
Crash Message:Failed to allocate a 8994568 byte allocation with 462080 free bytes and 451KB until OOM, target footprint 201326592, growth limit 201326592
java.lang.OutOfMemoryError: Failed to allocate a 8994568 byte allocation with 462080 free bytes and 451KB until OOM, target footprint 201326592, growth limit 201326592
at java.lang.StringFactory.newStringFromChars(StringFactory.java:260)
at java.lang.StringFactory.newStringFromBytes(StringFactory.java:245)
at java.lang.StringFactory.newStringFromBytes(StringFactory.java:54)
at java.io.ByteArrayOutputStream.toString(ByteArrayOutputStream.java:221)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:68)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:389)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2189)
```

### AndroidX Test and Android OS Versions

AndroidX Test Runner: 1.1.2-alpha01

### Link to a public git repo demonstrating the problem:

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the provided testWithInfiniteRecursion example, then inspect androidx.test.internal.runner.TestExecutor at TestExecutor.java:68, where the stacktrace is written to the summary writer. Done means the test runner reports the StackOverflowError without crashing with a secondary OutOfMemoryError.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.