-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement task-safe "current directory" #10463
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I like this idea! I'd want to make sure it could actually be supported though. Right now the main use cases for a "working directory" that I can think of are:
I believe that we can make a transition to a task-level current-working directory with those use cases. That being said, we shouldn't throw away the ability to change the os-level current working directory. Perhaps |
Does the same apply to getenv/setenv? No race there, but task-level envvars could be useful. |
@Jurily There is similar race on |
If we have the current directory as a task-local property, then we should rename |
What about external libs? They wouldn't know about Rust's task-local cwd. |
I'm wondering about the coverage of the use-cases that @alexcrichton outlined. The cwd is essentially a bit of process-level state that any system call might use. It's not obvious that we can make it task-local while retaining the right semantics for system calls. For example, we have a lot of functions in modules like
|
It's incorrect to implement a task-local directory with a |
cc #15643 |
As part of IO reform, we got |
I think this ticket should move to the RFCs wishlist. What we wound up with in IO reform is basically exposing the system APIs, which work with process-global working directories. On the posix side at least there are |
I'm going to close this in favor of a future to-be-opened RFC issue, but it's unlikely that we'll do this with today's design principles of the standard library (e.g. not adding our own abstractions on top) |
Add `let_with_type_underscore` lint Fixes rust-lang#10463 changelog: [`let_with_type_underscore`]: Add the lint.
Currently we provide
os::getcwd()
/os::change_dir()
via OS functions (libc::getcwd
or GetCurrentDirectory), but curdir information is maintained per-process, which means it is not thread-safe nor task-safe.Here is a sample code for current dir race:
So we must ban them and implement "current directory" using task-local storage.
The text was updated successfully, but these errors were encountered: