Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30504

Occasional StackOverflow using `downstreamParameterized` publisher

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • job-dsl-plugin
    • java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      Saw error in both: job-dsl-plugin 1.38 & 1.39-SNAPSHOT

      On our environment, we're occasionally seeing StackOverflows which seems to be traced to `downstreamParameterized`. When run on my local machine, I see the StackOverflow but am able to generate XML files. However, on a Jenkins instance, we're occasionally seeing jobs which hang/die and I think this might be the cause.

      This is the job definition I've been testing on:

      freeStyleJob('foo') {
          publishers {
              downstreamParameterized {
                  trigger('some_job') {
                      condition('UNSTABLE_OR_BETTER')
                      parameters {
                          currentBuild()
                          predefinedProps([
                                           parentJob: 'hao',
                                           artifactDir: 'blah',
                                           distribution: 'dev',
                                          ])
                      }
                  }
              }
          }
      }
      

          [JENKINS-30504] Occasional StackOverflow using `downstreamParameterized` publisher

          Hm, I ran your script 1000x, but could not reproduce any StackOverflowErrors. But I could reproduce JENKINS-30271 once. StackOverflowError should not occur "occationally". Are you sure that there are no other side-effects which lead to the StackOverflowError?

          Daniel Spilker added a comment - Hm, I ran your script 1000x, but could not reproduce any StackOverflowErrors. But I could reproduce JENKINS-30271 once. StackOverflowError should not occur "occationally". Are you sure that there are no other side-effects which lead to the StackOverflowError?

          Ray H added a comment -

          I tried running this against Java 7 and I did not see the StackOverflow error. Perhaps it's something that has changed from Java 7 to Java 8. What was the environment you were testing under?

          Ray H added a comment - I tried running this against Java 7 and I did not see the StackOverflow error. Perhaps it's something that has changed from Java 7 to Java 8. What was the environment you were testing under?

          I'm running Java 7. Jenkins still uses Groovy 1.8, but Groovy 2.3 is the first version that officially supports JDK 8. See http://www.groovy-lang.org/releasenotes/groovy-2.3.html. I recommend to use JDK 7 until JENKINS-21249 got solved.

          Daniel Spilker added a comment - I'm running Java 7. Jenkins still uses Groovy 1.8, but Groovy 2.3 is the first version that officially supports JDK 8. See http://www.groovy-lang.org/releasenotes/groovy-2.3.html . I recommend to use JDK 7 until JENKINS-21249 got solved.

          Ray H added a comment -

          That sounds reasonable. We also compile our own library using `job-dsl-plugin` and we match `job-dsl-plugin`'s dependency versions to avoid running into untested behavior.

          The bug is difficult to diagnose no a Jenkins instance, because when the StackOverflowError happens, the job enters a zombie state (and you can't cancel it JENKINS-30271) and the logs do not be shipped back to the Jenkins master so no one knows if/why "StackOverflowError" happens. I've tested this fix on a snapshot build on a Ubuntu Jenkins Master/Slave running Java 1.8 and the problem no longer

          Is this patch a reasonable solution considering that Jenkins supports use of Java8?

          Ray H added a comment - That sounds reasonable. We also compile our own library using `job-dsl-plugin` and we match `job-dsl-plugin`'s dependency versions to avoid running into untested behavior. The bug is difficult to diagnose no a Jenkins instance, because when the StackOverflowError happens, the job enters a zombie state (and you can't cancel it JENKINS-30271 ) and the logs do not be shipped back to the Jenkins master so no one knows if/why "StackOverflowError" happens. I've tested this fix on a snapshot build on a Ubuntu Jenkins Master/Slave running Java 1.8 and the problem no longer Is this patch a reasonable solution considering that Jenkins supports use of Java8 ?

          I could not reproduce the problem using JDK8 either. I hesitate to merge a patch for a bug that can not be reproduced. I would rather recommend to use Java 7 and log a warning when using the Job DSL with Java 8, since the Groovy version included in Jenkins is not support on JDK8.

          Daniel Spilker added a comment - I could not reproduce the problem using JDK8 either. I hesitate to merge a patch for a bug that can not be reproduced. I would rather recommend to use Java 7 and log a warning when using the Job DSL with Java 8, since the Groovy version included in Jenkins is not support on JDK8.

          unguiculus added a comment -

          I always get the StackOverflowError. Happens with both JDK 7 and JDK 8. I haven't tested it in Jenkins yet, only in the IDE or on the command-line. I use the following Gradle script:

          apply plugin: 'groovy'
          
          repositories {
          	mavenLocal()
          	maven {
          		name 'MyRepo'
          		url 'http://myrepo/'
          	}
          }
          
          dependencies {
          	compile 'org.jenkins-ci.plugins:job-dsl-core:1.38'
          	compile 'com.example.jenkins:job-dsl-base:2.3'
          }
          
          task wrapper(type: Wrapper) {
          	gradleVersion = '2.3'
          }
          
          task runJobDsl(type: JavaExec) {
          	main = 'javaposse.jobdsl.Run'
          	classpath = sourceSets.main.runtimeClasspath
          	workingDir = 'jobs'
          	args 'MyJobs.groovy'
          }
          
          task libs(type: Copy) {
          	into 'build/lib'
          	from configurations.compile {
          		include '**/*job-dsl-base*.jar'
          	}
          }
          
          

          unguiculus added a comment - I always get the StackOverflowError. Happens with both JDK 7 and JDK 8. I haven't tested it in Jenkins yet, only in the IDE or on the command-line. I use the following Gradle script: apply plugin: 'groovy' repositories { mavenLocal() maven { name 'MyRepo' url 'http: //myrepo/' } } dependencies { compile 'org.jenkins-ci.plugins:job-dsl-core:1.38' compile 'com.example.jenkins:job-dsl-base:2.3' } task wrapper(type: Wrapper) { gradleVersion = '2.3' } task runJobDsl(type: JavaExec) { main = 'javaposse.jobdsl.Run' classpath = sourceSets.main.runtimeClasspath workingDir = 'jobs' args 'MyJobs.groovy' } task libs(type: Copy) { into 'build/lib' from configurations.compile { include '**/*job-dsl-base*.jar' } }

          OK, now I'm able to reproduce this.

          build.gradle
          apply plugin: 'groovy'
          
          defaultTasks 'runJobDsl'
          
          repositories {
            maven {
              url 'http://repo.jenkins-ci.org/public/'
            }
          }
          
          dependencies {
            compile 'org.jenkins-ci.plugins:job-dsl-core:1.38'
          }
          
          task wrapper(type: Wrapper) {
            gradleVersion = '2.3'
          }
          
          task runJobDsl(type: JavaExec) {
            main = 'javaposse.jobdsl.Run'
            classpath = sourceSets.main.runtimeClasspath
            workingDir = 'jobs'
            args 'MyJobs.groovy'
          }
          
          jobs/MyJobs.groovy
          job('example') {
            publishers {
              downstreamParameterized {
                trigger('MyJob') {
                  condition('SUCCESS')
                  parameters {
                    concurrentBuild()
                    predefinedProp('Param1', 'foo')
                    predefinedProp('Param2', 'bar')
                  }
                }
              }
            }
          }
          

          But I still can't reproduce this in Jenkins or using the standalone jar:

          wget http://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/job-dsl-core/1.38/job-dsl-core-1.38-standalone.jar
          java -jar job-dsl-core-1.38-standalone.jar jobs/MyJobs.groovy
          

          Daniel Spilker added a comment - OK, now I'm able to reproduce this. build.gradle apply plugin: 'groovy' defaultTasks 'runJobDsl' repositories { maven { url 'http: //repo.jenkins-ci.org/ public /' } } dependencies { compile 'org.jenkins-ci.plugins:job-dsl-core:1.38' } task wrapper(type: Wrapper) { gradleVersion = '2.3' } task runJobDsl(type: JavaExec) { main = 'javaposse.jobdsl.Run' classpath = sourceSets.main.runtimeClasspath workingDir = 'jobs' args 'MyJobs.groovy' } jobs/MyJobs.groovy job( 'example' ) { publishers { downstreamParameterized { trigger( 'MyJob' ) { condition( 'SUCCESS' ) parameters { concurrentBuild() predefinedProp( 'Param1' , 'foo' ) predefinedProp( 'Param2' , 'bar' ) } } } } } But I still can't reproduce this in Jenkins or using the standalone jar: wget http: //repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/job-dsl-core/1.38/job-dsl-core-1.38-standalone.jar java -jar job-dsl-core-1.38-standalone.jar jobs/MyJobs.groovy

          Will be released in 1.39.

          Daniel Spilker added a comment - Will be released in 1.39.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: docs/Home.md http://jenkins-ci.org/commit/job-dsl-plugin/b0d37e65593bb0cd267c811f63c7c922427639b1 Log: Merge branch ' JENKINS-30504 ' Compare: https://github.com/jenkinsci/job-dsl-plugin/compare/feb3bb1ff48b...b0d37e65593b

          Ray H added a comment -

          Cheers. I should have specifically mentioned use of `gradle` to do this.

          Ray H added a comment - Cheers. I should have specifically mentioned use of `gradle` to do this.

            daspilker Daniel Spilker
            rymndhng Ray H
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: