You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DependencyTrack hangs when uploading a large SBOM to a project a second time #1905
When we create a new project and upload a large SBOM (~7.5MB) there is no problem. However, if we then upload the SBOM again to the same project, the DepTrack API server hangs and never finishes processing. Inspection of the logfile via Docker indicates a stack overflow error (java.lang.StackOverflowError), as shown in the attached logfile (DependencyTrackLog.txt).
This happens even if we wait a long time (several days) to upload the second SBOM.
For smaller SBOMs we never have this problem.
Steps to Reproduce:
Using the DependencyTrack API:
Create a new project
Upload a large SBOM (~7.5MB)
Verify that processing completes and the analysis is shown in the DepTrack UI.
Upload the SBOM once again to the previously created project.
DepTrack never finishes processing.
Expected Behavior:
Should be able to upload even large SBOMs multiple times to the same project.
Environment:
Dependency-Track Version: 4.5.0
Distribution: Docker
BOM Format & Version: CycloneDX 1.4 in JSON
Database Server: PostgreSQL
Browser: Various
Additional Details:
Unfortunately, we cannot send you the actual SBOM for proprietary reasons.
Wow, that's certainly a first. Ever seen anything like this happening before, @stevespringett?
2022-08-08 11:20:15,312 ERROR [LoggableUncaughtExceptionHandler] An unknown error occurred in an asynchronous event or notification thread
java.lang.StackOverflowError: null
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.datanucleus.state.StateManagerImpl.replaceStateManager(StateManagerImpl.java:2096)
at org.datanucleus.state.StateManagerImpl.initialiseForDetached(StateManagerImpl.java:644)
at org.datanucleus.state.StateManagerImpl.initialiseForDetached(StateManagerImpl.java:126)
at org.datanucleus.state.StateManagerImpl.detachCopy(StateManagerImpl.java:4932)
at org.datanucleus.state.StateManagerImpl.detachCopy(StateManagerImpl.java:126)
at org.datanucleus.ExecutionContextImpl.detachObjectCopy(ExecutionContextImpl.java:2741)
at org.datanucleus.store.fieldmanager.DetachFieldManager.processPersistableCopy(DetachFieldManager.java:76)
at org.datanucleus.store.fieldmanager.DetachFieldManager.processField(DetachFieldManager.java:154)
at org.datanucleus.store.fieldmanager.DetachFieldManager.internalFetchObjectField(DetachFieldManager.java:121)
at org.datanucleus.store.fieldmanager.AbstractFetchDepthFieldManager.fetchObjectField(AbstractFetchDepthFieldManager.java:105)
at org.datanucleus.state.StateManagerImpl.replacingObjectField(StateManagerImpl.java:1995)
at org.dependencytrack.model.Component.dnReplaceField(Component.java)
at org.dependencytrack.model.Component.dnReplaceFields(Component.java)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4320)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4345)
at org.datanucleus.state.StateManagerImpl.detachCopy(StateManagerImpl.java:4941)
at org.datanucleus.state.StateManagerImpl.detachCopy(StateManagerImpl.java:126)
at org.datanucleus.ExecutionContextImpl.detachObjectCopy(ExecutionContextImpl.java:2741)
at org.datanucleus.api.jdo.JDOPersistenceManager.jdoDetachCopy(JDOPersistenceManager.java:1121)
at org.datanucleus.api.jdo.JDOPersistenceManager.detachCopy(JDOPersistenceManager.java:1150)
at org.dependencytrack.persistence.ComponentQueryManager.createComponent(ComponentQueryManager.java:321)
at org.dependencytrack.persistence.QueryManager.createComponent(QueryManager.java:452)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:171)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
at org.dependencytrack.tasks.BomUploadProcessingTask.processComponent(BomUploadProcessingTask.java:178)
@JayAtFujifilm, would it be possible to provide the SBOM to us so we can try to reproduce the issue?
7.5MB isn't that large. The BOM I use to perform all my performance testing with is 22MB and contains just over 9K components. See attached Bloated BOMs.zip.
I think there's something else going on here, either memory or host configuration, or perhaps something in the BOM itself that contains an unexpected large amount of data in a field.
Looking at the code at line BomUploadProcessingTask.java:178 below, it is most likely a recursion issue (consistent with the stackoverflow error) due to a deep parent-child component hierarchy :
privatevoidprocessComponent(finalQueryManagerqm, finalBombom, Componentcomponent,
finalList<Component> flattenedComponents) {
component.setInternal(InternalComponentIdentificationUtil.isInternalComponent(component, qm));
....
if (component.getChildren() != null) {
for (finalComponentchild : component.getChildren()) {
processComponent(qm, bom, child, flattenedComponents); <-- Line #178
}
}
}
Would be interesting to know the maximum parent child relation depth in the problematic SBOM.
PS : Default stack size on OpenJDK 17 is 1024k which is already quite big.
Yup,
Just replicated with attached sbom with a depth of 14 recursive childs for component bcprov-jdk15onbom.txt.
It's a bit strange but first upload went ok, the issue appear at second upload.
The SBOM for which this occurs contains a deeply nested component hierarchy that mimics the layout of our source code. To build the SBOM, we iterate through our source code, building an individual SBOM for each project (.Net or NodeJS), and use the Cyclone CLI tool to merge the individual SBOMs. We also use "pseudo-components" to represent source code folders that don't directly contain a project.
Thanks for the update. FYI, at this time, Dependency-Track will flatten the component inventory and will not preserve hierarchy. Support for parent/child relationships for both projects and components is planned.
It would definitively help if you could provide your anonymized SBOM. My test SBOM is somewhat biased and extreme as I have duplicated the same component in the nested hierarchy probably causing an infinite recursion.
I tested again with the attached sbom (14 nested different components) bom-2.txt and everything run smoothly.
Nevertheless the algorithm could be improved to take that case into account.
What is important for reproduction will be to have :
Same number of components
Same nested component hierarchy
Consistent : if you replace componentA by some string, it should be the same everywhere
Given the error, the actual component names and identifiers (CPE, purls) are not relevant because it crashes before vuln analysis.
Activity
nscuro commentedon Aug 23, 2022
Wow, that's certainly a first. Ever seen anything like this happening before, @stevespringett?
@JayAtFujifilm, would it be possible to provide the SBOM to us so we can try to reproduce the issue?
stevespringett commentedon Aug 23, 2022
7.5MB isn't that large. The BOM I use to perform all my performance testing with is 22MB and contains just over 9K components. See attached Bloated BOMs.zip.
I think there's something else going on here, either memory or host configuration, or perhaps something in the BOM itself that contains an unexpected large amount of data in a field.
syalioune commentedon Aug 23, 2022
Hello Guys,
Looking at the code at line BomUploadProcessingTask.java:178 below, it is most likely a recursion issue (consistent with the stackoverflow error) due to a deep parent-child component hierarchy :
Would be interesting to know the maximum parent child relation depth in the problematic SBOM.
PS : Default stack size on OpenJDK 17 is 1024k which is already quite big.
syalioune commentedon Aug 23, 2022
Yup,
Just replicated with attached sbom with a depth of 14 recursive childs for component
bcprov-jdk15onbom.txt.It's a bit strange but first upload went ok, the issue appear at second upload.
JayAtFujifilm commentedon Aug 23, 2022
The SBOM for which this occurs contains a deeply nested component hierarchy that mimics the layout of our source code. To build the SBOM, we iterate through our source code, building an individual SBOM for each project (.Net or NodeJS), and use the Cyclone CLI tool to merge the individual SBOMs. We also use "pseudo-components" to represent source code folders that don't directly contain a project.
stevespringett commentedon Aug 23, 2022
Thanks for the update. FYI, at this time, Dependency-Track will flatten the component inventory and will not preserve hierarchy. Support for parent/child relationships for both projects and components is planned.
JayAtFujifilm commentedon Aug 26, 2022
Thank you, syalioune, for reproducing this so quickly!
syalioune commentedon Aug 28, 2022
It would definitively help if you could provide your anonymized SBOM. My test SBOM is somewhat biased and extreme as I have duplicated the same component in the nested hierarchy probably causing an infinite recursion.
I tested again with the attached sbom (14 nested different components) bom-2.txt and everything run smoothly.
Nevertheless the algorithm could be improved to take that case into account.
JayAtFujifilm commentedon Aug 30, 2022
We are working on trying to narrow down the cause the problem, and hope to have a smaller SBOM available for debugging soon.
sahil3112 commentedon Mar 15, 2023
Hi @syalioune ,
Can you please mention what information is required in anonymized,
The same issue is still in latest version
Will the Structure of SBOM help to debug?
syalioune commentedon Mar 16, 2023
What is important for reproduction will be to have :
Given the error, the actual component names and identifiers (CPE, purls) are not relevant because it crashes before vuln analysis.
sahil3112 commentedon Mar 28, 2023
Here is the SBOM structure, I have verified that we can reproduce the issue by using the structure SBOM
sbom.txt
6 remaining items
Add regression test for DependencyTrack/dependency-track#1905
nscuro commentedon Jul 5, 2023
@syalioune Apologies for the delayed response, I only now got some time to look at BOM processing more closely.
Agreed. I'd even go one step further: If
purlisnull, then also query forpurl == null.There are multiple issues closely related to this one. It all comes down to
matchSingleIdentitybeing too lax, see my comment here: #2519 (comment)For a change in Hyades, I now switched the matching logic to being "strict", and that fixes both #1905 and #2519: DependencyTrack/hyades-apiserver@6418879#diff-3a9c95d09a4a5285037a7d5ba65613e09198ce2b460279622cadd8e703677d40
Add regression test for DependencyTrack/dependency-track#1905
Add regression test for DependencyTrack/dependency-track#1905
Improve BOM processing performance and make it transactional (#218)
syalioune commentedon Jul 17, 2023
No pb. Same time issues here.
I guess the fix you performed in hyades would be merged back here sometime ?
nscuro commentedon Jul 17, 2023
Yes, we have many improvements from Hyades in the pipeline that we want to contribute back soon, and this is of course one of them. 🤘
melba-lopez commentedon Jul 28, 2023
@nscuro has this been addressed per #218? and would this be a 4.10 potential fix?
Improve BOM processing performance and make it transactional (#218)
github-actions commentedon Mar 26, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.