Stefan Monnier <[email protected]> writes: >>> `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).
We can't use this loop, we tipically pass a filename to be used to libgccjit and we have no control after (also see my last comment). >> 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. Surprised if it does or does not? > If you tell it to write to a pre-existing file, does > it fail with an error? I believe it does not. > If not, then I think it can't be used safely unless > *you* pre-create the file (e.g. with `make-temp-file`). Are we sure? Also if I pre-create the file with make-temp-file can't someone just replace it even more easily with the infamous link before libgccjit comes in? Thanks Andrea

