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

runnable_binary generated a zero-length wrapper, but succeeded #1267

Open
novas0x2a opened this issue Aug 22, 2024 · 0 comments
Open

runnable_binary generated a zero-length wrapper, but succeeded #1267

novas0x2a opened this issue Aug 22, 2024 · 0 comments

Comments

@novas0x2a
Copy link
Contributor

novas0x2a commented Aug 22, 2024

Sorry for how vague this is, still trying to figure out what might have happened. What we observed is:

  • The shell script that gets generated (i.e. ${name}_wrapper.sh) ended up as a zero-length file, but the action succeeded.
  • This meant that the empty script was uploaded to our remote cache, and broke other builds until we figured out what happened and cleaned it up.
  • We've only observed this once twice now.
  • This happened on Windows.

I'm still trying to figure out how it might have happened, but I'm guessing it's somehow Windows-related. I was curious if anyone else had seen this happen. Looking at the code, it seems like the only way this could have happened is if the sed failed and the script didn't notice (the >$@ would have created the output regardless of the sed). Maybe errexit should have caught it? I don't understand currently, since genrules are supposed to run with errexit. I don't have a reliable repro or anything, unfortunately, though I'm trying.

novas0x2a added a commit to novas0x2a/rules_foreign_cc that referenced this issue Aug 24, 2024
In bazel-contrib#1267 there was an issue where, somehow, the wrapper script ended up as
a zero-length file but the action succeeded (resulting in storing a
zero-length file instead of the script in the caches). genrules are
documented as running inside `-ueo pipefail` so it seems like
this should be impossible...

In any case, this avoids using >$@ because the > runs before the command
itself does, creating a zero-length file before populating it, and is
the only way I could think of that this ends up as an empty file.
Hopefully, if the problem repeats, genrule will notice that the file
didn't get created and fail.
novas0x2a added a commit to novas0x2a/rules_foreign_cc that referenced this issue Aug 24, 2024
In bazel-contrib#1267 there was an issue where, somehow, the wrapper script ended up as
a zero-length file but the action succeeded (resulting in storing a
zero-length file instead of the script in the caches). genrules are
documented as running inside `-ueo pipefail` so it seems like
this should be impossible...

In any case, this avoids using >$@ because the > runs before the command
itself does, creating a zero-length file before populating it, and is
the only way I could think of that this ends up as an empty file.
Hopefully, if the problem repeats, genrule will notice that the file
didn't get created and fail.
novas0x2a added a commit to novas0x2a/rules_foreign_cc that referenced this issue Aug 24, 2024
In bazel-contrib#1267 there was an issue where, somehow, the wrapper script ended up as
a zero-length file but the action succeeded (resulting in storing a
zero-length file instead of the script in the caches). genrules are
documented as running inside `-ueo pipefail` so it seems like
this should be impossible...

In any case, this avoids using >$@ because the > runs before the command
itself does, creating a zero-length file before populating it, and is
the only way I could think of that this ends up as an empty file.
Hopefully, if the problem repeats, genrule will notice that the file
didn't get created and fail.

SH_BINARY_FILENAME also wasn't used, so this skips a step.
novas0x2a added a commit to novas0x2a/rules_foreign_cc that referenced this issue Aug 26, 2024
In bazel-contrib#1267 there was an issue where, somehow, the wrapper script ended up as
a zero-length file but the action succeeded (resulting in storing a
zero-length file instead of the script in the caches). genrules are
documented as running inside `-ueo pipefail` so it seems like
this should be impossible...

In any case, this avoids using >$@ because the > runs before the command
itself does, creating a zero-length file before populating it, and is
the only way I could think of that this ends up as an empty file.
Hopefully, if the problem repeats, genrule will notice that the file
didn't get created and fail.

SH_BINARY_FILENAME also wasn't used, so this skips a step.
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

No branches or pull requests

1 participant