Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear CpsBodyExecution.thread #925

Merged
merged 2 commits into from
Aug 26, 2024
Merged

Conversation

jglick
Copy link
Member

@jglick jglick commented Aug 24, 2024

Seems to fix a problem I had originally tried to solve with #923 but misclassified. Similar in spirit to #368 and more directly to #367 (comment) before that was reverted. Did not try to modify isLaunched(); it is not clear under which conditions we would care. Open to other suggestions.

@jglick jglick requested a review from a team as a code owner August 24, 2024 15:31
@jglick jglick added the bug label Aug 24, 2024
@jglick jglick requested a review from dwnusbaum August 24, 2024 15:31
for (var semaphore : semaphores) {
SemaphoreStep.success(semaphore + "/1", null);
}
r.assertBuildStatusSuccess(r.waitForCompletion(b));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without fix:

Started
[Pipeline] Start of Pipeline
[Pipeline] parallel
[Pipeline] { (Branch: x1)
[Pipeline] { (Branch: x2)
[Pipeline] }
[Pipeline] echo
2
[Pipeline] }
[Pipeline] // parallel
[Pipeline] parallel
[Pipeline] { (Branch: y1)
[Pipeline] { (Branch: y2)
[Pipeline] semaphore
[Pipeline] semaphore
an exception which occurred:
	in object of type org.jenkinsci.plugins.workflow.cps.FlowHead
	in field org.jenkinsci.plugins.workflow.cps.CpsThread.head
	in object org.jenkinsci.plugins.workflow.cps.CpsThread@98ddd75
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThread
	in field org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.thread
	in object org.jenkinsci.plugins.workflow.cps.CpsBodyExecution@380efbea
	in object of type org.jenkinsci.plugins.workflow.cps.CpsBodyExecution
	in field org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.this$0
	in object org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter@4bdab55d
	in object of type org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter
	in field com.cloudbees.groovy.cps.impl.CallEnv.returnAddress
	in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@2cdbbf26
	in object of type com.cloudbees.groovy.cps.impl.FunctionCallEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.TryBlockEnv@62056750
	in object of type com.cloudbees.groovy.cps.impl.TryBlockEnv
	in field com.cloudbees.groovy.cps.impl.CallEnv.caller
	in object com.cloudbees.groovy.cps.impl.ClosureCallEnv@2d9b1151
	in object of type com.cloudbees.groovy.cps.impl.ClosureCallEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@33f539e2
	in object of type com.cloudbees.groovy.cps.impl.BlockScopeEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@42a69235
	in object of type com.cloudbees.groovy.cps.impl.BlockScopeEnv
	in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
	in object com.cloudbees.groovy.cps.impl.CpsClosureDef@bd042d6
	in object of type com.cloudbees.groovy.cps.impl.CpsClosureDef
	in field com.cloudbees.groovy.cps.impl.CpsClosure.def
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7e34cb64
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in object of type java.util.LinkedHashMap
	in object of type WorkflowScript
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@6494c769
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in object of type java.util.HashMap
	in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@12d5c6f4
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThreadGroup
Caused: java.lang.IllegalStateException: FlowHead loading problem at deserialize: Null FlowHead with id 4 in execution CpsFlowExecution[Owner[p/1:p #1]]
	at org.jenkinsci.plugins.workflow.cps.FlowHead.readResolve(FlowHead.java:207)
	at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callReadResolve(JDKSpecific.java:213)
	at org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:311)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1422)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
	at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
	at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:531)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:498)
	at java.base/java.util.HashMap.readObject(HashMap.java:1560)
	at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callReadObject(JDKSpecific.java:171)
	at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:252)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1808)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
	at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
	at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:531)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:498)
	at com.cloudbees.groovy.cps.SerializableScript.readObject(SerializableScript.java:30)
	at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callReadObject(JDKSpecific.java:171)
	at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:252)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1808)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1777)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:149)
	at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:135)
	at org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:53)
	at org.jboss.marshalling.river.RiverObjectInputStream.readObjectOverride(RiverObjectInputStream.java:307)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:531)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:498)
	at java.base/java.util.HashMap.readObject(HashMap.java:1560)
	at org.jboss.marshalling.reflect.JDKSpecific$SerMethods.callReadObject(JDKSpecific.java:171)
	at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:252)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1808)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:246)
	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1918)
	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1831)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1421)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:298)
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:231)
	at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:41)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:331)
	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader$SandboxedUnmarshaller.sandbox(RiverReader.java:250)
	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader$SandboxedUnmarshaller.readObject(RiverReader.java:263)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:879)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:872)
	at org.jenkinsci.plugins.workflow.support.concurrent.Futures$1.run(Futures.java:147)
	at org.jenkinsci.plugins.workflow.support.concurrent.DirectExecutor.execute(DirectExecutor.java:33)
	at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1286)
	at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:760)
	at org.jenkinsci.plugins.workflow.support.concurrent.Futures.addCallback(Futures.java:157)
	at org.jenkinsci.plugins.workflow.support.concurrent.Futures.addCallback(Futures.java:97)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.loadProgramAsync(CpsFlowExecution.java:869)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onLoad(CpsFlowExecution.java:836)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getExecution(WorkflowRun.java:719)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:577)
	at hudson.model.RunMap.retrieve(RunMap.java:233)
	at hudson.model.RunMap.retrieve(RunMap.java:61)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:657)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:639)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.getByNumber(AbstractLazyLoadRunMap.java:537)
	at hudson.model.RunMap.getById(RunMap.java:213)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.run(WorkflowRun.java:968)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.get(WorkflowRun.java:980)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList.resume(FlowExecutionList.java:226)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl.onLoaded(FlowExecutionList.java:217)
	at jenkins.model.Jenkins.<init>(Jenkins.java:1045)
	at hudson.model.Hudson.<init>(Hudson.java:86)
	at org.jvnet.hudson.test.JenkinsRule.newHudson(JenkinsRule.java:746)
	at org.jvnet.hudson.test.JenkinsRule.before(JenkinsRule.java:408)
	at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:649)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.lang.Thread.run(Thread.java:1583)
ERROR: Failed to load program
Finished: FAILURE

@@ -176,6 +176,7 @@ private void checkAllDone(boolean stepFailed) {
} else {
handler.context.onSuccess(success);
}
// TODO should this also bodies.clear()?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The originally observed error, which I was unable to reproduce exactly in a functional test, involved the CpsBodyExecution being held from ParallelStepExecution.bodies:

an exception which occurred:
	in object of type org.jenkinsci.plugins.workflow.cps.FlowHead
	in field org.jenkinsci.plugins.workflow.cps.CpsThread.head
	in object org.jenkinsci.plugins.workflow.cps.CpsThread@282f4605
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThread
	in field org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.thread
	in object org.jenkinsci.plugins.workflow.cps.CpsBodyExecution@6c50e364
	in object of type org.jenkinsci.plugins.workflow.cps.CpsBodyExecution
	in element at index [1] of size [3]
	in field org.jenkinsci.plugins.workflow.cps.steps.ParallelStepExecution.bodies
	in object org.jenkinsci.plugins.workflow.cps.steps.ParallelStepExecution@4416bb37
	in object of type org.jenkinsci.plugins.workflow.cps.steps.ParallelStepExecution
	in field org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler.stepExecution
	in object org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler@253b016b
	in object of type org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler
	in field org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback.handler
	in object org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback@1193a1ed
	in object of type org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback
	in element at index [0] of size [1]
	in field org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.callbacks
	in object org.jenkinsci.plugins.workflow.cps.CpsBodyExecution@4a46a38c
	in object of type org.jenkinsci.plugins.workflow.cps.CpsBodyExecution
	in field org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.this$0
	in object org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter@3bf876f0
	in object of type org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter
	in field com.cloudbees.groovy.cps.impl.CallEnv.returnAddress
	in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@463508bd
	in object of type com.cloudbees.groovy.cps.impl.FunctionCallEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.TryBlockEnv@4aa5555f
	in object of type com.cloudbees.groovy.cps.impl.TryBlockEnv
	in field com.cloudbees.groovy.cps.impl.CallEnv.caller
	in object com.cloudbees.groovy.cps.impl.ClosureCallEnv@3500c544
	in object of type com.cloudbees.groovy.cps.impl.ClosureCallEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4d376ae2
	in object of type com.cloudbees.groovy.cps.impl.BlockScopeEnv
	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@23a9e319
	in object of type com.cloudbees.groovy.cps.impl.BlockScopeEnv
	in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
	in object com.cloudbees.groovy.cps.impl.CpsClosureDef@43c6459e
	in object of type com.cloudbees.groovy.cps.impl.CpsClosureDef
	in field com.cloudbees.groovy.cps.impl.CpsClosure.def
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@705f8247
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in object of type java.util.LinkedHashMap
	in object of type WorkflowScript
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@64986d4
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@6a940c2f
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@1b0f4e56
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@174eaaca
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@5dfbe1d1
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@17446b35
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@76d8ea75
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@1422169e
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@165588a2
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@227c449e
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@13c699e6
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@1754fbe6
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@2d7e6136
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@6d6698b3
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in field groovy.lang.Closure.delegate
	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@4ac82550
	in object of type org.jenkinsci.plugins.workflow.cps.CpsClosure2
	in object of type java.util.HashMap
	in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7a736c24
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThreadGroup
Caused: java.lang.IllegalStateException: FlowHead loading problem at deserialize: Null FlowHead with id … in execution …
	at org.jenkinsci.plugins.workflow.cps.FlowHead.readResolve(FlowHead.java:207)
	at …

In this case the ParallelStepExecution was complete, so there was no reason for it to still be holding onto its bodies. (There was no good reason for program.dat to be holding onto the ParallelStepExecution itself; this was due to a forgotten def.)

AtomicReference<Path> buildXml = new AtomicReference<>();
rr.then(r -> {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("parallel x1: {}, x2: {g = {x -> x + 1}; echo(/${g(1)}/)}; parallel y1: {semaphore 'y1'}, y2: {semaphore 'y2'}", true));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note lack of def on g)

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoying that we could have fixed this 4 years ago, but oh well. Did you run it through the PCT?

@jglick
Copy link
Member Author

jglick commented Aug 26, 2024

Did you run it through the PCT?

Not yet, but seems prudent.

@jglick
Copy link
Member Author

jglick commented Aug 26, 2024

Passes @cloudbees PCT.

@jglick jglick merged commit 7935cbe into jenkinsci:master Aug 26, 2024
16 checks passed
@jglick jglick deleted the capturedBodies branch August 26, 2024 16:21
@dwnusbaum
Copy link
Member

Did not try to modify isLaunched(); it is not clear under which conditions we would care.

Oh and for what it's worth, I looked at this a bit and it is also not not clear to me that it matters. If it does cause problems as-is, I think we could add || isDone() to the method to make the behavior closer to what it was previously.

@basil
Copy link
Member

basil commented Sep 4, 2024

JENKINS-73726 FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants