Comments (13)
We should probably just unconditionally call really_init.
That would fix rust-lang/rustc_codegen_cranelift#1048 on Linux + glibc too.
from rust.
uh.
from rust.
@rjsberry Could you clarify: Does this problem arise with code ran on an ordinary gnu system? Say, a Debian container? Or x86_64-unknown-linux-musl
itself?
from rust.
I can take a guess at why this happens. For glibc targets we assume that the arguments can be retrieved without needing to store argc
and argv
. However if this musl compatibility layer doesn't use the .init_array
then we can't retrieve them.
from rust.
Ah yeah, it seems that behavior is a GNU extension that Rich Felker doesn't want to support?
from rust.
Does env::args()
just not work at all on musl if we're a cdylib, then?
from rust.
Correct. When libstd's start function isn't used, env::args()
only works on Windows, macOS and Linux with Glibc. On any other target it returns an empty list.
from rust.
Apparently we already have this comment:
rust/library/std/src/sys/pal/unix/args.rs
Lines 101 to 107 in 07d0d7c
In other words, we are already hacking around this issue for the miri emulator, and not using the fact that we are still given argv "naturally" via execve.
We should probably just unconditionally call really_init
.
from rust.
Note that this was intentionally done #66547 but there have been other issues #105999
from rust.
@ChrisDenton I still think we can consider #105999 to still be fixed, as we just get our char **argv
and it will be the same thing, even if the char*
s behind the char**
have been rearranged, right? So we'll set the atomics twice to the same value, which sounds very Working As Intended.
from rust.
One other thought: if we initialize arguments this way, we don't also need to initialize them in our main function in binaries. Can you compile out that code on linux-gnu?
— @joshtriplett in #66547 (review)
Well, given the remarks here seem to position this as a "wouldn't it be nice if we didn't do extra work?" and that this seems to be non-resilient in practice, as it has caused more than one open issue, I think we should be unafraid of doing a bit of extra computation.
from rust.
I more meant that the fact that libraries mess about with (what should be) immutable memory is a safety issue so ideally we would parse it at the point where it's least likely that the are multiple threads. But people would probably complain about doing unnecessary allocating and extra work pre-main.
Just storing argc and argv should be cheap though so I'm definitely not arguing against that.
from rust.
the dilemma: strictly conforming posix programs shouldn't mutate argc and argv, but strictly conforming posix programs also shouldn't be aware of argc and argv if if they're dylibs, eh?
from rust.
Related Issues (20)
- ICE: `layout mismatch for result of MulWithOverflow` HOT 4
- ReentrantLockGuard's Sync impl is unsound HOT 2
- use osc 8 hyperlinks to link to the reference for lints when they are printed HOT 1
- frameworks not supported error HOT 6
- compiletest should note when test output is normalized HOT 1
- Uncredible virtual memory usage when compile, maybe memory leak HOT 1
- PhantomData confusing documentation
- Performance regression between v1.76.0 and v1.77.2 HOT 10
- Nightly rustc panic when compiling a simple no_std program HOT 4
- Wrong import hint HOT 1
- add a custom diagnostic for type mismatches of constants
- Compilation bug while using Diesel framework HOT 6
- ICE: `could not resolve upvar: LocalVarId(HirId(DefId)))`
- Compiler creates unnecessary pointer to the value on ownership transfering. HOT 7
- ICE: coherence: `assertion failed: obligations.is_empty()` / `unexpected infer in QueryInput ` HOT 2
- unused_associated_type_bounds are usable and useful
- ICE: cannot convert `'{erased}` to a region vid HOT 2
- Bootstrap build fails: found crate `serde_derive` compiled by an incompatible version of rustc HOT 15
- long literal expressions should be truncated HOT 21
- Clean out old msys2/mingw stuff in CI HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.