gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 28 forks source link

fix: prevent race condition in PackageDirs #52

Closed oliverpool closed 1 year ago

oliverpool commented 1 year ago

I saw the following log, where the package and extrafiles are mixed up:

Including extra files for Go packages:

  github.com/oliverpool/grafana-armv6
    will include extra files in the root file system
      from extrafiles/github.com/oliverpool/grafana-armv6
      last modified: 2023-03-01T22:25:30+01:00 (454h57m51s ago)

  tailscale.com/cmd/tailscaled
    will include extra files in the root file system
      from /home/olivier/go/pkg/mod/github.com/oliverpool/grafana-armv6@v1.0.3-v8.5.21/_gokrazy/extrafiles
      last modified: 2023-03-01T21:14:00+01:00 (456h9m20s ago)

This sounded like a concurrency issue, and sure enough the packer.PackageDirs function does not return the dirs in the same order as the argument, as expected by (note the idx): https://github.com/gokrazy/tools/blob/69473ec010f406f8125665ff28f2bd6490f9bfcb/internal/packer/packer.go#L579-L595

This PR fixes this.

stapelberg commented 1 year ago

Thank you!