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

IOException: "cannot find current thread"

    Details

    • Similar Issues:
    • Released As:
      workflow-cps 2.69

      Description

      Our server has intermittently been raising an exception which fails builds: 

      java.io.IOException: cannot find current thread
      at org.jenkinsci.plugins.workflow.cps.CpsStepContext.doGet(CpsStepContext.java:300)
      at org.jenkinsci.plugins.workflow.cps.CpsBodySubContext.doGet(CpsBodySubContext.java:88)
      at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:67)
      at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Callback.finished(BindingStep.java:254)
      at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution2$Callback2.finished(BindingStep.java:162)
      at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution$TailCall.lambda$onSuccess$0(GeneralNonBlockingStepExecution.java:140)
      at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE

      It happens across different projects, and we can't find any commonality between them that might explain how we're ending up in this state. The error is not repeatable – kicking off the build again usually results in a successful build.

      Jenkins ver. 2.164.1

      (Relevant?) plugin versions:
      Pipeline Multibranch: 2.20
      Pipeline: Groovy 2.63

      I found the line that is throwing the exception in the source code, which seems straightforward, but I don't know why that value is sometimes null.

      I'm happy to provide more information to help diagnose this problem if you need something more.

        Attachments

          Activity

          Hide
          jglick Jesse Glick added a comment -

          I wonder if there could be other problems with running the completion callback in GeneralNonBlockingStepExecution on a separate thread (maybe we need to fix that instead of just making the collection thread safe)

          Long before this API was introduced, steps were sometimes calling StepContext.get from arbitrary threads, whether that happened to be part of callback processing or not. (simple example) It is expected to be thread-safe.

          Show
          jglick Jesse Glick added a comment - I wonder if there could be other problems with running the completion callback in GeneralNonBlockingStepExecution on a separate thread (maybe we need to fix that instead of just making the collection thread safe) Long before this API was introduced, steps were sometimes calling StepContext.get from arbitrary threads, whether that happened to be part of callback processing or not. ( simple example ) It is expected to be thread-safe.
          Hide
          dnusbaum Devin Nusbaum added a comment -

          A potential fix for this issue was just released in version 2.69 of Pipeline Groovy Plugin. I was never able to reproduce the issue in a test, so there is a possibility that it is still not fixed, so if you still see the issue in version 2.69 please reopen the ticket and include the stack trace you are getting.

          Show
          dnusbaum Devin Nusbaum added a comment - A potential fix for this issue was just released in version 2.69 of Pipeline Groovy Plugin. I was never able to reproduce the issue in a test, so there is a possibility that it is still not fixed, so if you still see the issue in version 2.69 please reopen the ticket and include the stack trace you are getting.
          Hide
          mjanczuk Mateusz Janczuk added a comment -

          Devin Nusbaum thanks for the fix  I did update 2 days ago to Pipeline Groovy Plugin 2.69, and it looks that exception disappeared. Before upgrade I saw exception at least 2 times a day, after updating, not once (Jenkins LTS 2.164.3).

          Show
          mjanczuk Mateusz Janczuk added a comment - Devin Nusbaum thanks for the fix  I did update 2 days ago to Pipeline Groovy Plugin 2.69, and it looks that exception disappeared. Before upgrade I saw exception at least 2 times a day, after updating, not once (Jenkins LTS 2.164.3).
          Hide
          ringerc Craig Ringer added a comment -

          FWIW, I found a possibly-related crash that turned out to be in my own code. I was using a groovy `Map` that was modified by multiple closures run within a `parallel` step. This caused similar exceptions as well as odd incorrect map entries etc.

          So keep an eye out for that. Posting here for people who see this later.

          Show
          ringerc Craig Ringer added a comment - FWIW, I found a possibly-related crash that turned out to be in my own code. I was using a groovy `Map` that was modified by multiple closures run within a `parallel` step. This caused similar exceptions as well as odd incorrect map entries etc. So keep an eye out for that. Posting here for people who see this later.
          Hide
          jglick Jesse Glick added a comment -

          Craig Ringer that ought to be safe, since the CPS VM runs green threads, and in no event should it cause an error like the one reported here which is below userspace. If you can reproduce such a problem, please file it separately.

          Show
          jglick Jesse Glick added a comment - Craig Ringer that ought to be safe, since the CPS VM runs green threads, and in no event should it cause an error like the one reported here which is below userspace. If you can reproduce such a problem, please file it separately.

            People

            • Assignee:
              dnusbaum Devin Nusbaum
              Reporter:
              fcodyc Cody Casterline
            • Votes:
              18 Vote for this issue
              Watchers:
              32 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: