apache / apache/maven-surefire

[SUREFIRE-1808] OutOfMemoryError running with TestNG

Open
#3,042 2 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Jingfei Hu](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jingfei)** opened **[SUREFIRE-1808](https://issues.apache.org/jira/browse/SUREFIRE-1808?redirect=false)** and commented

Hi team,

We've been suffering OutOfMemory intermittently in our test labs recently. The call stack is below 

```
[ERROR] Java heap space -> [Help 1]
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$CloseableCloser.run(ForkStarter.java:200)
at org.apache.maven.surefire.shade.common.org.apache.maven.shared.utils.cli.CommandLineUtils$1.call(CommandLineUtils.java:301)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:615)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1161)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1002)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:848)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
```

 

Our test case count is +4k and still increasing, and pass rate is around 95% for each execution. The OOM error is not always reproducible. And we set memory dump parameters, but there is no dump file generated when it occurs. 

The line of code throwing the exception is below. 

!image-2020-12-29-15-16-28-566.png|width=763,height=460!

 

More version information:

maven-surefire-plugin: 3.0.0-M3

testng: 6.4

maven: 3.2.5

---

**Affects:** 3.0.0-M3

**Attachments:**
- [image-2020-12-29-13-31-31-539.png](https://issues.apache.org/jira/secure/attachment/13017789/image-2020-12-29-13-31-31-539.png) (_560.81 kB_)
- [image-2020-12-29-13-58-44-076.png](https://issues.apache.org/jira/secure/attachment/13017790/image-2020-12-29-13-58-44-076.png) (_783.34 kB_)
- [image-2020-12-29-15-16-28-566.png](https://issues.apache.org/jira/secure/attachment/13017792/image-2020-12-29-15-16-28-566.png) (_731.64 kB_)
- [image-2020-12-29-17-14-42-884.png](https://issues.apache.org/jira/secure/attachment/13017808/image-2020-12-29-17-14-42-884.png) (_1.87 MB_)
- [image-2020-12-29-17-18-56-557.png](https://issues.apache.org/jira/secure/attachment/13017807/image-2020-12-29-17-18-56-557.png) (_18.27 kB_)
- [image-2020-12-29-17-19-51-660.png](https://issues.apache.org/jira/secure/attachment/13017806/image-2020-12-29-17-19-51-660.png) (_37.45 kB_)

1 votes, 3 watchers

Contributor guide

Open the contributing guide

Research direction

The stack trace points to ForkStarter.java, including lines 200, 615, and 283; start there and reproduce with the reported TestNG, Surefire, and Maven versions and a large test suite. Since no target behavior or test file is specified, establish a bounded reproduction and an observable success condition for preventing the intermittent heap failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.