Skip to content

cannot mutate statics in initalizer of another static #56903

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

Closed
Mark-Simulacrum opened this issue Dec 17, 2018 · 3 comments · Fixed by #56916
Closed

cannot mutate statics in initalizer of another static #56903

Mark-Simulacrum opened this issue Dec 17, 2018 · 3 comments · Fixed by #56916
Assignees
Labels
P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Mark-Simulacrum
Copy link
Member

https://crater-reports.s3.amazonaws.com/beta-1.32-1/beta-2018-12-05/gh/oxidizers.drdns/log.txt

Dec 08 20:04:10.309 INFO [stderr] error: cannot mutate statics in the initializer of another static
Dec 08 20:04:10.309 INFO [stderr]    --> src/buffer.rs:279:17
Dec 08 20:04:10.309 INFO [stderr]     |
Dec 08 20:04:10.309 INFO [stderr] 279 |     x: unsafe { &mut STDOUT_BUFFER_SPACE as *mut [u8] as *mut u8 },
Dec 08 20:04:10.309 INFO [stderr]     |                 ^^^^^^^^^^^^^^^^^^^^^^^^
Dec 08 20:04:10.309 INFO [stderr] 
Dec 08 20:04:10.309 INFO [stderr] error: cannot mutate statics in the initializer of another static
Dec 08 20:04:10.310 INFO [stderr]    --> src/buffer.rs:293:17
Dec 08 20:04:10.310 INFO [stderr]     |
Dec 08 20:04:10.310 INFO [stderr] 293 |     x: unsafe { &mut STDERR_BUFFER_SPACE as *mut [u8] as *mut u8 },
Dec 08 20:04:10.310 INFO [stderr]     |                 ^^^^^^^^^^^^^^^^^^^^^^^^
Dec 08 20:04:10.310 INFO [stderr] 
@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Dec 17, 2018
@oli-obk oli-obk self-assigned this Dec 17, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Dec 17, 2018

cc @tarcieri

Repro

static mut STDERR_BUFFER_SPACE: [u8; 42] = [0u8; 42];

pub static mut STDERR_BUFFER: *mut [u8] = unsafe { &mut STDERR_BUFFER_SPACE };

I'm going to fix the regression, but I just want to note that https://github.com/oxidizers/drdns/blob/98c1153a09642c2a5d8d2ed77ef7d9429d94995a/src/buffer.rs#L292 is very dangerous to use. This looks like another argument for #53639

@tarcieri
Copy link
Contributor

FWIW the code in question is some mechanically translated C with the translation performed by corrode. I have pretty much abandoned that project.

pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 20, 2018
… r=davidtwco

Fix a recently introduced regression

fixes rust-lang#56903
@pnkfelix
Copy link
Member

triage: P-high.

@pnkfelix pnkfelix added the P-high High priority label Dec 20, 2018
Centril added a commit to Centril/rust that referenced this issue Dec 22, 2018
… r=davidtwco

Fix mutable references in `static mut`

fixes rust-lang#56903
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
… r=davidtwco

Fix mutable references in `static mut`

fixes rust-lang#56903
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
… r=davidtwco

Fix mutable references in `static mut`

fixes rust-lang#56903
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2018
… r=davidtwco

Fix mutable references in `static mut`

fixes rust-lang#56903
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants