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

[SR-11541] Handle failure in the Driver's getTemporaryFilePath helper #53942

Open
belkadan opened this issue Sep 28, 2019 · 4 comments
Open

[SR-11541] Handle failure in the Driver's getTemporaryFilePath helper #53942

belkadan opened this issue Sep 28, 2019 · 4 comments

Comments

@belkadan
Copy link
Contributor

@belkadan belkadan commented Sep 28, 2019

Previous ID SR-11541
Radar rdar://problem/55600413
Original Reporter @belkadan
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, Driver
Assignee None
Priority Medium

md5: b1cf20b9e827a8612b37edfdaddd6d35

Issue Description:

const char *
ToolChain::JobContext::getTemporaryFilePath(const llvm::Twine &name,
                                            StringRef suffix) const {
  SmallString<128> buffer;
  std::error_code EC = llvm::sys::fs::createTemporaryFile(name, suffix, buffer);
  if (EC) {
    // FIXME: This should not take down the entire process.
    llvm::report_fatal_error("unable to create temporary file for filelist");
  }

  C.addTemporaryFile(buffer.str(), PreserveOnSignal::Yes);
  // We can't just reference the data in the TemporaryFiles vector because
  // that could theoretically get copied to a new address.
  return C.getArgs().MakeArgString(buffer.str());
}

This is obviously not optimal. The immediate action is to return an llvm::Expected<const char *> instead, to represent the failure, but all of the callers are constructing command-lines for the jobs to run for this compilation. That's not currently something that can fail.

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Sep 28, 2019

Forgot to mention: a possible failure reason is that TMPDIR is set to a non-existent or read-only directory.

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Sep 28, 2019

Compilation::getAllSourcesPath has a similar problem.

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Sep 28, 2019

And the writeAllSourcesFile helper, by contrast, is diagnosing and failing gracefully.

@belkadan
Copy link
Contributor Author

@belkadan belkadan commented Oct 1, 2019

Looks like some of the other places emitting diag::error_unable_to_make_temporary_file are not recovering gracefully, though.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant