This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Fix infinite loop when mkstemp fails
ClosedPublic

Authored by rprichard on Jul 20 2022, 5:34 PM.

Details

Summary

mkstemp is guaranteed to make at least TMP_MAX attempts to create the
random file, and if it can't, it fails with EEXIST. get_temp_file_name
shouldn't call mkstemp again if it fails with anything other than
EEXIST. A single mkstemp call seems sufficient.

On Android, I've seen mkstemp fail with:

  • EROFS (because cwd wasn't set to a writable filesystem)
  • EACCES (because cwd pointed to a dir owned by root, but the test program was running as the shell user instead)

Previously, get_temp_file_name would run forever in these situations.

See D4962 and "llvm-svn: 229035"

Diff Detail

Event Timeline

rprichard created this revision.Jul 20 2022, 5:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 5:34 PM
rprichard requested review of this revision.Jul 20 2022, 5:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 5:34 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jul 21 2022, 4:39 PM
ldionne added a subscriber: ldionne.

LGTM, but please rebase onto main to trigger CI and get a clean run.

This revision is now accepted and ready to land.Jul 21 2022, 4:39 PM
This revision was automatically updated to reflect the committed changes.