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

Accessing unset global variable cause master to hang

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      If I have a global lib file vars/config.groovy like this:

      def getFoo()  { return this.foo }
      
      def setFoo(String value) {
          if (this.foo == null) {
              this.foo = value
          } else {
              logImmutableWarning('foo', this.foo, value)
          }
      }
      

      and I call

      echo config.foo
      

      my Jenkins master hangs with 100% CPU.

      If I call

      config.foo = 'bar'
      echo config.foo
      

      it works fine.

      Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.

      Aborted by N N
      Click here to forcibly terminate running steps
      Click here to forcibly kill entire build
      

      Only way I know to fix this is to restart master.

      I do not think the extra setter logic is responsible for this.

      I updated this issue because the problem was bigger than I understood at first.

      Original issue

      Reading global variable in own file cause stack overflow

      In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:

      def getSomething() { return this.something ?: 'somethingDefaultValue' }
      

      leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

      Trying to fix this followng the standard groovy way and adding:

      String something
      

      does not help.

        Attachments

          Issue Links

            Activity

            marcus_phi Marcus Philip created issue -
            marcus_phi Marcus Philip made changes -
            Field Original Value New Value
            Summary Reading global variable in own file cause stack overflow Accessing unset global variable cause stack overflow
            marcus_phi Marcus Philip made changes -
            Description In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.

            Original Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            marcus_phi Marcus Philip made changes -
            Description
            Original Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            marcus_phi Marcus Philip made changes -
            Description If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }

            def setFoo(String value) {
                if (this.foo == null) {
                    this.foo = value
                } else {
                    logImmutableWarning('foo', this.foo, value)
                }
            }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            I do not think the extra setter logic is repsonsible for this.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            marcus_phi Marcus Philip made changes -
            Description If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }

            def setFoo(String value) {
                if (this.foo == null) {
                    this.foo = value
                } else {
                    logImmutableWarning('foo', this.foo, value)
                }
            }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            I do not think the extra setter logic is repsonsible for this.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }

            def setFoo(String value) {
                if (this.foo == null) {
                    this.foo = value
                } else {
                    logImmutableWarning('foo', this.foo, value)
                }
            }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            I do not think the extra setter logic is responsible for this.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            marcus_phi Marcus Philip made changes -
            Priority Minor [ 4 ] Critical [ 2 ]
            marcus_phi Marcus Philip made changes -
            Environment Pipeline Shared Groovy Libraries Plugin - 2.2 (=latest)
            marcus_phi Marcus Philip made changes -
            Link This issue relates to JENKINS-34416 [ JENKINS-34416 ]
            marcus_phi Marcus Philip made changes -
            Description If I have a global lib file /vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }

            def setFoo(String value) {
                if (this.foo == null) {
                    this.foo = value
                } else {
                    logImmutableWarning('foo', this.foo, value)
                }
            }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            I do not think the extra setter logic is responsible for this.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            If I have a global lib file vars/config.groovy like this:
            {code:java}
            def getFoo() { return this.foo }

            def setFoo(String value) {
                if (this.foo == null) {
                    this.foo = value
                } else {
                    logImmutableWarning('foo', this.foo, value)
                }
            }
            {code}
            and I call
            {code:java}
            echo config.foo
            {code}
            my Jenkins master hangs with 100% CPU.

            If I call
            {code:java}
            config.foo = 'bar'
            echo config.foo
            {code}
            it works fine.

            Note that it's impossible to kill the job properly and that CPU is still 100% and a thread is still available even after klicking links in build log.
            {code}
            Aborted by N N
            Click here to forcibly terminate running steps
            Click here to forcibly kill entire build
            {code}
            Only way I know to fix this is to restart master.

            I do not think the extra setter logic is responsible for this.

            _I updated this issue because the problem was bigger than I understood at first._

            h4. Original issue
            h5. Reading global variable in own file cause stack overflow
            In have a file in the pipeline global functions (vars/) that has properties. I want to have a default value. But this implementation:
            {code:java}
            def getSomething() { return this.something ?: 'somethingDefaultValue' }
            {code}
            leads to Jenkins master taking 100% CPU and hanging in what I believe is a stack overflow error. But it's very hard to get any info from logs or thread dumps.

            Trying to fix this followng the standard groovy way and adding:
            {code:java}
            String something
            {code}
            does not help.
            marcus_phi Marcus Philip made changes -
            Summary Accessing unset global variable cause stack overflow Accessing unset global variable cause master to hang
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-31484 [ JENKINS-31484 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-31484 [ JENKINS-31484 ]
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-31484 [ JENKINS-31484 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "workflow-cps-global-lib PR 29 (Web Link)" [ 15351 ]
            jglick Jesse Glick made changes -
            Labels documentation
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            jglick Jesse Glick made changes -
            Resolution Duplicate [ 3 ]
            Status In Review [ 10005 ] Resolved [ 5 ]
            leedega Kevin Phillips made changes -
            Link This issue relates to JENKINS-45834 [ JENKINS-45834 ]

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              marcus_phi Marcus Philip
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: