Skip to content

[BUG] spec.CargohomeDeps may return nil which will cause debug.Cargohome to panic #929

@invidian

Description

@invidian

Expected Behavior

All scenarios to be handled gracefully.

Actual Behavior

With input like this:

diff --git test/source_test.go test/source_test.go
index fd6732f..94de109 100644
--- test/source_test.go
+++ test/source_test.go
@@ -760,7 +760,6 @@ index ea874f5..ba38f84 100644
                                stat, err := ref.StatFile(ctx, gwclient.StatRequest{
                                        Path: dep,
                                })
-
                                if err != nil {
                                        t.Fatal(err)
                                }
@@ -990,18 +989,18 @@ func TestSourceWithCargohome(t *testing.T) {
                const contextName = "multi-cargo-module"
                spec := &dalec.Spec{
                        Name: "test-dalec-cargo-context-source",
-                       Sources: map[string]dalec.Source{
-                               "src": {
-                                       Context: &dalec.SourceContext{Name: contextName},
-                                       Generate: []*dalec.SourceGenerator{
-                                               {
-                                                       Cargohome: &dalec.GeneratorCargohome{
-                                                               Paths: []string{"./dir/module1", "./dir/module2"},
+                       /*                      Sources: map[string]dalec.Source{
+                                               "src": {
+                                                       Context: &dalec.SourceContext{Name: contextName},
+                                                       Generate: []*dalec.SourceGenerator{
+                                                               {
+                                                                       Cargohome: &dalec.GeneratorCargohome{
+                                                                               Paths: []string{"./dir/module1", "./dir/module2"},
+                                                                       },
+                                                               },
                                                        },
                                                },
-                                       },
-                               },
-                       },
+                                       },*/
                        Dependencies: &dalec.PackageDependencies{
                                Build: map[string]dalec.PackageConstraints{
                                        "rust": {

Panic occurs:

        runtime.panicmem
        	runtime/panic.go:262
        runtime.sigpanic
        	runtime/signal_unix.go:925
        github.com/project-dalec/dalec/frontend/debug.Cargohome.func1
        	github.com/project-dalec/dalec/frontend/debug/handle_cargohome.go:39
        github.com/project-dalec/dalec/frontend.BuildWithPlatformFromUIClient.func1
        	github.com/project-dalec/dalec/frontend/build.go:159
        github.com/moby/buildkit/frontend/dockerui.(*Client).Build.func1
        	github.com/moby/buildkit@v0.25.2/frontend/dockerui/build.go:39
        golang.org/x/sync/errgroup.(*Group).Go.func1
        	golang.org/x/sync@v0.18.0/errgroup/errgroup.go:93
        runtime.goexit
        	runtime/asm_amd64.s:1693

Steps To Reproduce

  1. Modify tests as mentioned.
  2. Run tests as go test -run SourceWithCargohome/multi-module ./test

Are you willing to submit PRs to contribute to this bug fix?

  • Yes, I am willing to implement it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions