jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
531 stars 230 forks source link

"panic: runtime error: invalid memory address or nil pointer dereference" when running "jfrog rt bp" #1297

Closed trettstadtnlb closed 2 years ago

trettstadtnlb commented 2 years ago

Describe the bug When running jfrog rt bp in my Github workflow, I get the following error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9c7623]

goroutine 1 [running]:
github.com/jfrog/jfrog-client-go/artifactory/buildinfo.mergeDependencies(0xc000580800, 0xc0005808e0)
    /root/go/pkg/mod/github.com/jfrog/jfrog-client-go@v1.5.2/artifactory/buildinfo/buildinfo.go:96 +0x1e3
github.com/jfrog/jfrog-client-go/artifactory/buildinfo.mergeModules(0xc000162c50, 0xc000580880)
    /root/go/pkg/mod/github.com/jfrog/jfrog-client-go@v1.5.2/artifactory/buildinfo/buildinfo.go:74 +0x65
github.com/jfrog/jfrog-client-go/artifactory/buildinfo.(*BuildInfo).Append(0xc000306000, 0x7f5c9236a600)
    /root/go/pkg/mod/github.com/jfrog/jfrog-client-go@v1.5.2/artifactory/buildinfo/buildinfo.go:59 +0xdc
github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo.(*BuildPublishCommand).Run(0xc000185a10)
    /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/v2@v2.4.2/artifactory/commands/buildinfo/publish.go:90 +0xe7
github.com/jfrog/jfrog-cli-core/v2/common/commands.Exec({0xf14510, 0xc000185a10})
    /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/v2@v2.4.2/common/commands/command.go:26 +0xad
github.com/jfrog/jfrog-cli/artifactory.buildPublishCmd(0xc0000eaf20)
    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/artifactory/cli.go:2048 +0x14e
github.com/jfrog/jfrog-cli/artifactory.GetCommands.func9(0x1)
    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/artifactory/cli.go:232 +0x19
github.com/codegangsta/cli.HandleAction({0xc888c0, 0xe01cf8}, 0xd)
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:490 +0x5a
github.com/codegangsta/cli.Command.Run({{0xdb8ec8, 0xd}, {0x0, 0x0}, {0xc0001b6a00, 0x1, 0x1}, {0x0, 0x0}, {0xde13ad, ...}, ...}, ...)
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:210 +0x8f8
github.com/codegangsta/cli.(*App).RunAsSubcommand(0xc00019e680, 0xc0000eac60)
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:379 +0x985
github.com/codegangsta/cli.Command.startApp({{0xdb1806, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...)
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:298 +0x6bb
github.com/codegangsta/cli.Command.Run({{0xdb1806, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...)
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:98 +0x418
github.com/codegangsta/cli.(*App).Run(0xc00019e4e0, {0xc000030090, 0x3, 0x3})
    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:255 +0x6ac
main.execMain()
    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:105 +0x285
main.main()
    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:84 +0x25

To Reproduce So far the problem only occurs in one of our projects. In all other projects publishing build information works most of the time and if it fails, a restart of the build works. I am willing to create a minimal project that reproduces the error, but I think I need some help from a developer for that.

Expected behavior Publishing build information should not throw an error.

Screenshots If applicable, add screenshots to help explain your problem.

Versions

Additional context In the Github workflow, the JFrog CLI is used in the following steps:

  1. Set up mvn with jfrog rt mvnc
  2. Run jfrog rt mvn install to build the project
  3. Run jfrog rt mvn docker:build to build the docker image
  4. Run jfrog rt dp to push the Docker image
  5. Run jfrog rt bag, jfrog rt bce and finally jfrog rt bp
eyalbe4 commented 2 years ago

Thanks for reporting this issue @trettstadtnlb. Will you be able to check if replacing only the jfrog rt mvn docker:build command with mvn docker:build makes the issie disappear? Please let us know. In case it does - this provides us with a hint to root cause of the issue.

trettstadtnlb commented 2 years ago

Thank you for the quick reply, @eyalbe4. Replacing jfrog rt mvn docker:build with mvn docker:build worked and we will use that as a workaround for now. But I'm still willing to do more testing, if needed.

eyalbe4 commented 2 years ago

Gerat @trettstadtnlb! So we now know what causes the issue. We definitely want to get this issue fixed. We'll update this issue once this is resolved.

sstephant commented 2 years ago

Hello, I have a similar issue with the jfrog CLI with some projects Tested with 2.5.1 / 2.6.2 / 2.8.0 on our CI platform (in a maven:3.5.3-jdk-8 docker image) Basically the workflow is as follow:

  1. server setup with jfrog rt config add
  2. maven setup with jfrog rt mvn-config
  3. jfrog rt mvn clean compile -U -Dartifactory.publish.artifacts=false
  4. `jfrog rt mvn test -Dartifactory.publish.artifacts=false
  5. jfrog rt mvn sonar:sonar -DskipTests -Dartifactory.publish.artifacts=false
  6. jfrog rt mvn install -DskipTests
  7. jfrog rt bag
  8. jfrog rt bce
  9. jfrog rt bp
  10. ...

Disabling steps 3, 4, 5 allows to publish build info without exception, but some of the steps which pull additionnal dependencies do not seem to work without jfrog command prefix so we're stuck

Here's the stack for jfrog 2.8.0 , error is in the same spot (comparing sha1 of build-info deps w/ partials deps)

16:26:37  panic: runtime error: invalid memory address or nil pointer dereference
16:26:37  [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9c8f6a]
16:26:37  
16:26:37  goroutine 1 [running]:
16:26:37  github.com/jfrog/build-info-go/entities.mergeDependencies(0xc000601400, 0xc000601560)
16:26:37    /root/go/pkg/mod/github.com/jfrog/build-info-go@v0.1.4/entities/buildinfo.go:161 +0x1ea
16:26:37  github.com/jfrog/build-info-go/entities.mergeModules(0xc00020cbe0, 0xc000601500)
16:26:37    /root/go/pkg/mod/github.com/jfrog/build-info-go@v0.1.4/entities/buildinfo.go:139 +0x65
16:26:37  github.com/jfrog/build-info-go/entities.(*BuildInfo).Append(0xc000678000, 0x2f)
16:26:37    /root/go/pkg/mod/github.com/jfrog/build-info-go@v0.1.4/entities/buildinfo.go:77 +0xdc
16:26:37  github.com/jfrog/build-info-go/build.(*Build).ToBuildInfo(0xc0000b0000)
16:26:37    /root/go/pkg/mod/github.com/jfrog/build-info-go@v0.1.4/build/build.go:127 +0x154
16:26:37  github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo.(*BuildPublishCommand).Run(0xc0004c22a0)
16:26:37    /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/v2@v2.7.0/artifactory/commands/buildinfo/publish.go:103 +0x20a
16:26:37  github.com/jfrog/jfrog-cli-core/v2/common/commands.Exec({0xf343b8, 0xc0004c22a0})
16:26:37    /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/v2@v2.7.0/common/commands/command.go:26 +0xad
16:26:37  github.com/jfrog/jfrog-cli/artifactory.buildPublishCmd(0xc0000d31e0)
16:26:37    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/artifactory/cli.go:1632 +0x125
16:26:37  github.com/jfrog/jfrog-cli/artifactory.GetCommands.func9(0x1)
16:26:37    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/artifactory/cli.go:225 +0x19
16:26:37  github.com/codegangsta/cli.HandleAction({0xca0980, 0xe1f3a8}, 0xd)
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:490 +0x5a
16:26:37  github.com/codegangsta/cli.Command.Run({{0xdd5989, 0xd}, {0x0, 0x0}, {0xc000242790, 0x1, 0x1}, {0x0, 0x0}, {0xdfe907, ...}, ...}, ...)
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:210 +0x8f8
16:26:37  github.com/codegangsta/cli.(*App).RunAsSubcommand(0xc00022a680, 0xc0000d2f20)
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:379 +0x985
16:26:37  github.com/codegangsta/cli.Command.startApp({{0xdce14a, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...)
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:298 +0x6bb
16:26:37  github.com/codegangsta/cli.Command.Run({{0xdce14a, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, ...}, ...}, ...)
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/command.go:98 +0x418
16:26:37  github.com/codegangsta/cli.(*App).Run(0xc00022a4e0, {0xc000030180, 0x3, 0x3})
16:26:37    /root/go/pkg/mod/github.com/codegangsta/cli@v1.20.0/app.go:255 +0x6ac
16:26:37  main.execMain()
16:26:37    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:87 +0x2e5
16:26:37  main.main()
16:26:37    /var/jenkins_home/workspace/eco-system/release/jfrog-cli-release/temp/jfrog-cli/main.go:65 +0x25
sstephant commented 2 years ago

We found a workaround for the time being which consists of configuring the JFROG_CLI_BUILD_xxx variables only for the mvn install command and not for the entire pipeline. It seems the root cause of the problem is that in a multimodule maven projet not all the artifacts get a sha1 in the jfrog build partials info depending on the maven command executed.

Or-Geva commented 2 years ago

Hi @sstephant & @trettstadtnlb. JFrog-CLI V2.12.0 includes a fix for this issue. Feel free to upgrade and let us know how it goes.

Jan-Pleva commented 1 year ago

Isnt this issue similar to this thred? Can you help me with this? https://github.com/jfrog/build-info-go/issues/163

Found tool in cache: jf 2.37.1 x64 Running jfrog-cli from /opt/hostedtoolcache/jf/2.37.1/x64/jf JFrog CLI version: 2.37.1 Executing JFrog CLI Command: /opt/hostedtoolcache/jf/2.37.1/x64/jf c add "Marvin3.VBtOModule.Client.JFrog.Yaml_20230518.2_jfrog_cli_cmd_1684404202880" --url="https://artifactory.skoda.vwgroup.com/" --interactive=false --access-token-stdin Executing JFrog CLI Command: /opt/hostedtoolcache/jf/2.37.1/x64/jf c use "Marvin3.VBtOModule.Client.JFrog.Yaml_20230518.2_jfrog_cli_cmd_1684404202880" 12:03:22 [Info] Using server ID 'Marvin3.VBtOModule.Client.JFrog.Yaml_20230518.2_jfrog_cli_cmd_1684404202880' (https://artifactory.skoda.vwgroup.com/) Executing JFrog CLI Command: /opt/hostedtoolcache/jf/2.37.1/x64/jf yarn-config --repo-resolve=front-npm-virtual 12:03:22 [Info] yarn build config successfully created. Executing JFrog CLI Command: /opt/hostedtoolcache/jf/2.37.1/x64/jf yarn install --no-immutable --build-name=marvin-external-app --build-number=20230518.2 12:03:23 [Info] Running Yarn... 12:03:24 [Info] Preparing for dependencies information collection... For the first run of the build, the dependencies collection may take a few minutes. Subsequent runs should be faster. ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: Done in 0s 80ms panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xc3332e]

goroutine 1 [running]: github.com/jfrog/build-info-go/build.(YarnModule).appendDependencyRecursively(0xc0005240d8?, 0xc00033f410?, {0x1af2b70?, 0xc0005240d8?, 0xc00065ae70?}, 0x7fcf1c3b79b8?, 0xc00031d590?) /root/go/pkg/mod/github.com/jfrog/build-info-go@v1.9.3/build/yarn.go:97 +0x2e github.com/jfrog/build-info-go/build.(YarnModule).getDependenciesMap(0xc000335340) /root/go/pkg/mod/github.com/jfrog/build-info-go@v1.9.3/build/yarn.go:91 +0x93 github.com/jfrog/build-info-go/build.(YarnModule).Build(0xc000335340) /root/go/pkg/mod/github.com/jfrog/build-info-go@v1.9.3/build/yarn.go:72 +0x85 github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/yarn.(YarnCommand).Run(0xc0003646e0) /root/go/pkg/mod/github.com/jfrog/jfrog-cli-core/v2@v2.32.1/artifactory/commands/yarn/yarn.go:108 +0x365 github.com/jfrog/jfrog-cli-core/v2/common/commands.Exec({0x125f8b0?, 0xc0003646e0})`