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

test_sbom_details_cyclonedx_osv cause stack overflow errors #1322

Open
ctron opened this issue Feb 20, 2025 · 6 comments
Open

test_sbom_details_cyclonedx_osv cause stack overflow errors #1322

ctron opened this issue Feb 20, 2025 · 6 comments
Labels
Developer experience Enhancements to improve our team's Dev experience, including tooling, docs and workflows.

Comments

@ctron
Copy link
Contributor

ctron commented Feb 20, 2025

test_sbom_details_cyclonedx_osv causes a stack overflow:

 thread 'sbom::details::test_sbom_details_cyclonedx_osv' has overflowed its stack
fatal runtime error: stack overflow
@helio-frota helio-frota added the Developer experience Enhancements to improve our team's Dev experience, including tooling, docs and workflows. label Feb 25, 2025
@helio-frota
Copy link
Collaborator

can we close this ? 👍

@helio-frota
Copy link
Collaborator

has relation with #1344 but I'm not sure if that is the same

@ctron
Copy link
Contributor Author

ctron commented Feb 25, 2025

That PR simply hides this issue, but doesn't resolve it.

@ctron ctron added this to the Trustify 2.1.0 milestone Feb 25, 2025
@ctron ctron added this to Trustify Feb 25, 2025
@ctron ctron moved this to Backlog in Trustify Feb 25, 2025
@helio-frota
Copy link
Collaborator

@ctron @chirino @jcrossley3

I think I found the places where stack overflows occur, they are commented together, as it is a stack error that must be at the limit... un-commenting one or the other will cause the error. The cause may be these functions or other previous ones that used up stack space.

As you can see now I have assertion error:

──── STDERR:             trustify-module-fundamental::fundamental sbom::details::sbom_details_cyclonedx_osv

thread 'sbom::details::sbom_details_cyclonedx_osv' panicked at modules/fundamental/tests/sbom/details.rs:90:5:
assertion `left == right` failed
  left: 11
 right: 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure
────────────
     Summary [   1.358s] 1 test run: 0 passed, 1 failed, 389 skipped
        FAIL [   1.348s] trustify-module-fundamental::fundamental sbom::details::sbom_details_cyclonedx_osv
error: test run failed
➜  trustify git:(test-stack) ✗ git diff
diff --git a/modules/fundamental/tests/sbom/details.rs b/modules/fundamental/tests/sbom/details.rs
index 6f093e27..93fefce7 100644
--- a/modules/fundamental/tests/sbom/details.rs
+++ b/modules/fundamental/tests/sbom/details.rs
@@ -12,13 +12,13 @@ use trustify_test_context::TrustifyContext;
 #[instrument]
 async fn sbom_details_cyclonedx_osv(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
     // get the env var RUST_MIN_STACK and make sure it set to 50000000
-    let stack_size = env::var("RUST_MIN_STACK").unwrap_or("".to_string());
-    if stack_size != "50000000" {
-        println!(
-            "skipping sbom_details_cyclonedx_osv test, RUST_MIN_STACK=50000000 env var is not set"
-        );
-        return Ok(());
-    }
+    // let stack_size = env::var("RUST_MIN_STACK").unwrap_or("".to_string());
+    // if stack_size != "50000000" {
+    //     println!(
+    //         "skipping sbom_details_cyclonedx_osv test, RUST_MIN_STACK=50000000 env var is not set"
+    //     );
+    //     return Ok(());
+    // }

     let sbom = SbomService::new(ctx.db.clone());

diff --git a/modules/ingestor/src/graph/sbom/cyclonedx.rs b/modules/ingestor/src/graph/sbom/cyclonedx.rs
index 56884363..655547d4 100644
--- a/modules/ingestor/src/graph/sbom/cyclonedx.rs
+++ b/modules/ingestor/src/graph/sbom/cyclonedx.rs
@@ -145,22 +145,22 @@ impl SbomContext {
                     .as_ref()
                     .map(|cpe| Cpe::from_str(cpe.as_ref()))
                     .transpose()?;
-                let pr = self
-                    .graph
-                    .ingest_product(
-                        component.name.clone(),
-                        ProductInformation {
-                            vendor: component.publisher.clone().map(|p| p.to_string()),
-                            cpe: product_cpe,
-                        },
-                        connection,
-                    )
-                    .await?;
-
-                if let Some(ver) = component.version.clone() {
-                    pr.ingest_product_version(ver.to_string(), Some(self.sbom.sbom_id), connection)
-                        .await?;
-                }
+                // let pr = self
+                //     .graph
+                //     .ingest_product(
+                //         component.name.clone(),
+                //         ProductInformation {
+                //             vendor: component.publisher.clone().map(|p| p.to_string()),
+                //             cpe: product_cpe,
+                //         },
+                //         connection,
+                //     )
+                //     .await?;
+
+                // if let Some(ver) = component.version.clone() {
+                //     pr.ingest_product_version(ver.to_string(), Some(self.sbom.sbom_id), connection)
+                //         .await?;
+                // }

                 // create component

@@ -199,7 +199,7 @@ impl SbomContext {

         // create

-        creator.create(connection, &mut processors).await?;
+        // creator.create(connection, &mut processors).await?;

         // done

@helio-frota
Copy link
Collaborator

We have recursion here

@ctron
Copy link
Contributor Author

ctron commented Mar 7, 2025

Good find! I think you could try to "box" it (putting it on the heap). Something like:

let creator = Box::new(creator);

Maybe that's the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer experience Enhancements to improve our team's Dev experience, including tooling, docs and workflows.
Projects
Status: Backlog
Development

No branches or pull requests

2 participants