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

cmd/go: 'build output "...." already exists and is not an object file' error after interrupted compilation #57039

Open
woody77 opened this issue Dec 2, 2022 · 6 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@woody77
Copy link

woody77 commented Dec 2, 2022

What version of Go are you using (go version)?

$ go version
go version go1.19.3 linux/amd64

Does this issue reproduce with the latest release?

Unknown.

What did you do?

Rough steps:

  1. Interrupt a build with ^C
  2. Make some changes that cause our build system to attempt to rebuild the binary (like git rebase)
  3. Run the build

What did you expect to see?

No error.

What did you see instead?

go build go.fuchsia.dev/fuchsia/tools/fidl/fidlmerge: build output "../../../../fidlmerge" already exists and is not an object file

Upon inspection, the file starts with 4KB of 0x00s, which definitely isn't an object file. But the block of the file at 0x1000 does match the contents of the file that's written by the compiler if I delete the "bad" file and re-run the build.

@woody77
Copy link
Author

woody77 commented Dec 2, 2022

The only workaround seems to be to delete the output file and try again.

@seankhliao
Copy link
Member

is this using the go tool or bazel ?

@bcmills
Copy link
Member

bcmills commented Dec 2, 2022

Possibly related to #53804 (CC @golang/compiler)?

@tamird
Copy link
Contributor

tamird commented Dec 2, 2022

Yes, looks related. This is using the go tool.

@cherrymui
Copy link
Member

The 4KB of zeros could be related to #53804 (which is a kernel bug as far as we understand). But this issue is about interrupting a build with ctrl-C, which leaves more uncertainty and could result in a corrupted file in other ways.

I think this issue is more about whether the go command should emit an error for an existing non-object output file (possibly due to corruption)? If so, this would be working as intended.

@woody77
Copy link
Author

woody77 commented Dec 2, 2022

As a user, it seems like the wrong behavior for the go tool to be unable to build if there is an output file that it created (even if invalid due to an interrupted build). Ideally, it wouldn't leave the file in an invalid state on cancellation (^C).

@prattmic prattmic changed the title 'build output "...." already exists and is not an object file' error after interrupted compilation cmd/go: 'build output "...." already exists and is not an object file' error after interrupted compilation Dec 5, 2022
@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 5, 2022
@seankhliao seankhliao added the GoCommand cmd/go label Dec 6, 2022
@seankhliao seankhliao added this to the Unplanned milestone Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants