2 ms·
Slap a mutex on that beast! This is expected behavior for setting a GLOBAL variable without a lock on the memoryspace..
by Khelavaster 3y ago
Slap a mutex on that beast!
This is expected behavior for setting a GLOBAL variable without a lock on the memoryspace..
- krackers 3y agoYou can't guarantee that whatever libraries you pull in use the same mutex as you though.
- JaDogg 3y agowho pull in libraries in C like this?
- agevag 3y ago[dead]
- Tobu 3y agoWho doesn't? libc itself calls getenv when getting system time: https://news.ycombinator.com/item?id=38344224 https://news.ycombinator.com/item?id=38344224 You may have a mutex on getenv/setenv, like the Rust stdlib does, but when libc doesn't look at that mutex, even on the read side, you run into UB. So the next step is never calling into seemingly innocent libc functions in safe code (which you have to enforce on your dependencies as well), implementing safe alternatives to a good chunk of libc (and making sure your dependencies use those), to cordon off anything that looks at the environment. This makes a good chunk of POSIX functionality useless.
- JaDogg 3y agoOK thank you for the explanation.. This makes more more scared to bring in libraries :(
- seeknotfind 3y agoI thought they were talking about inside the libc implementation. Though, if that was done and people call getenv from async contexts, it could deadlock.