>> `make-temp-name` uses `O_EXCL | O_CREAT` so as to close the race >> condition: if someone predicated the filename, we detect it atomically >> and we try again. >> >> You might like to check >> >> >> https://wiki.sei.cmu.edu/confluence/display/c/FIO21-C.+Do+not+create+temporary+files+in+shared+directories > > Thanks for the pointer. > > I'm still not really convinced we have a problem here with trampolines. > With `make-temp-file' we are really only choosing the filename and > suggesting it to libgccjit, this last one will perform the file > creation.
The important part is the use of `O_EXCL | O_CREAT` when creating the file. *BUT* `O_EXCL | O_CREAT` will fail if the file already exists. Which is why `make-temp-file` needs `make-temp-name` to generate new names until we find one that really doesn't exist (not just at the time `make-temp-name` is called but the fraction of a millisecond later when we do try to create it). > I'd be surprised if GCC does not handle this correctly, and > in case shouldn't this be a GCC bug? I'd be surprised. If you tell it to write to a pre-existing file, does it fail with an error? If not, then I think it can't be used safely unless *you* pre-create the file (e.g. with `make-temp-file`). Stefan