title: Jenkins throwing java.lang.StackOverflowError -- Not just on unstash
body: <p>Update July 31, 2019<br>
  The error sometimes happens before the unstash call, but always on the same server. In an effort to see if the problem was caused by unstash working in a directory where it needed to overwrite files, I cleaned the directory -- but the problem still happened. This time the output began (transcribed, any typos are my fault):</p>
  
  <pre><code>Running on my_agent in C:/Jenkins/workspace/script_name
  . . .
  Running in D:\mydir
  [Pipeline] {
  [Pipeline] bat
  [mydir] Running batch script
  D:\mydir&gt; dir .
  &lt;output of dir command&gt;
  [Pipeline] End of Pipeline
  java.lang.StackOverflowError
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:115)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:778)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
  etc.
  </code></pre>
  
  <p>It did not reach the unstash call, but still got the same error.<br>
  = = = = =<br>
  Getting java.lang.StackOverflowError when unstashing in Jenkins on Windows 10; happens on one server but not another. Looks like unstash is getting infinite recursion.</p>
  
  <ul>
  <li>Same name for stash and unstash? -- yes; using same function to unstash on each.</li>
  <li>Reboot Jenkins master and slaves -- yes.</li>
  <li>Enough room on disk to unstash? -- yes.</li>
  <li>Web search on this error -- yes, but this problem not addressed.</li>
  <li>Has this worked in past? -- yes, unstash is working on one server but not another.</li>
  <li>Is target directory clean? -- yes.</li>
  <li>Tried at distinct times? -- yes.</li>
  </ul>
  
  <pre><code>def stash_my_stuff() {
      stash includes: '**', name: 'my_stash'
  }
  def unstash_my_stuff() {
      unstash 'my_stash'
  }
  
  // on one agent
  dir("d:\\tmsc") { unstash_my_stuff() }
  
  // later on a different agent
  dir("d:\\tmsc") { unstash_my_stuff() }
  </code></pre>
  
  <pre><code>13:23:33 Running in D:\tmsc
  [Pipeline] {
  [Pipeline] unstash
  [Pipeline] }
  [Pipeline] // dir
  [Pipeline] dir
  13:24:01 Running in D:\tmsc
  [Pipeline] {
  [Pipeline] End of Pipeline
  java.lang.StackOverflowError
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:111)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
      at org.jboss.marshalling.river.RiverMarshaller.doSerializableObject(RiverMarshaller.java:988)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:778)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
      at org.jboss.marshalling.river.RiverMarshaller.doSerializableObject(RiverMarshaller.java:988)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
      at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
  etc., etc., etc.
  sometimes it also includes
      at org.jboss.marshalling.river.RiverMarshaller.doSerializableObject(RiverMarshaller.java:967)
  </code></pre>