Skip to content

Prevent source corruption from overlapping input paths - #217

Open
r4venrudy wants to merge 1 commit into
google:masterfrom
r4venrudy:fix/overlapping-input-paths
Open

r4venrudy wants to merge 1 commit into
google:masterfrom
r4venrudy:fix/overlapping-input-paths

Conversation

@r4venrudy

Copy link
Copy Markdown

Fixes #114 for overlapping paths within one invocation.

Passing both a directory and one of its files schedules concurrent addLicense calls for the same file. A worker can read the file after another worker truncates it, then replace the source with a header or a partial read. Normalize paths to cleaned absolute paths and deduplicate them before starting workers.

Add a CLI subprocess regression that mixes directory, relative-file, and absolute-file inputs. It verifies one modification, one header, and preservation of the complete original source. Against the original implementation, all five runs modified the file 10–30 times; four also corrupted the source. The patched implementation passes 20 repeated runs and five runs with the race detector.

Validation on Windows with Go 1.23.0:

  • go test -run TestOverlappingPaths -count=20 -v — passed.
  • go test -race -run TestOverlappingPaths -count=5 — passed.
  • go test -skip 'Test(Read|Write)Errors' -v ./... — passed, with the repository’s original LF fixture bytes. The two existing chmod-based permission tests were excluded because chmod is unavailable in this Windows environment.
  • go vet ./..., build, gofmt, and git diff --check — passed.

The Linux CI matrix remains to be run upstream.

@google-cla

google-cla Bot commented Oct 11, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent failure

1 participant