-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix setenv and getenv (especially on os x) #1333
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
Summarizing the discussion around this on irc:
|
Eventually we're going to need some sort of singleton tasks to hold a default IO loop |
See also #884 |
Ugh, how ghastly. I think the way I'd prefer to do this is to complete #553 -- add support for global variables as "unsafe elements of a module" -- and then add some utility functions to the runtime that (say) take a pointer-to-a-global and either atomically install a mutex in it or return a mutex already present in it. Then build a resource type that encapsulates that and we can write global-lock-guarded code in rust. (Or some similar atomic-op-on-a-global abstraction; suggestions welcome) Not great but we'll need unsafe globals for a few other grotty parts of hoisting rt code up into rust (logging, say). |
Personally I am not too concerned about memory leaks in setenv/getenv. I imagine this isn't fixed yet because people rarely set environment variables more than once or twice over the course of program execution. |
Probably see also #878 |
Still blocked on #553. |
I actually got an double free error at one point when running the time::tests. I saved the report here: |
I'm going to put this on my list for 0.3 but may not get to it for a while. If somebody else wants to fix it then be my guest. |
Fixed by 46cc11e |
I digged a bit into setenv/getenv not always working on os x and found two issues:
Sadly the man page says:
maybe this can be patched up either by an additional unsetenv call /or/
by setting a maximum buffer value when unset/size checking after having been set from rust.
setenv/getenv are not safe for concurrent use (acording to IEEE Std 1003.1, 2004 Edition) and thus
should be wrapped by a task that processes set/get commands and is started on demand /or/ protected
by a lock in the runtime. opinions on the correct approach wanted.
The text was updated successfully, but these errors were encountered: