Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRefCell complains two mutable borrows present when only one exist on armv7-unknown-linux-gnueabihf #40593
Comments
MJDSys
changed the title
RefCell complains two mutable borrows present when one exist on armv7-unknown-linux-gnueabihf
RefCell complains two mutable borrows present when only one exist on armv7-unknown-linux-gnueabihf
Mar 17, 2017
This comment has been minimized.
This comment has been minimized.
|
This may be related to rust-openssl/issues/597. It would appear like dropping of values is broken in the nightly and beta toolchain: This works: let mutex = Mutex::new(());
let mut guard = None;
guard = Some(mutex.lock().unwrap());
drop(guard.take().unwrap());
mutex.try_lock().unwrap(); // locks as expectedbut this fails: let mutex = Mutex::new(());
let mut guard = None;
guard = Some(mutex.lock().unwrap());
drop(guard.take()); // unwrap() removed
mutex.try_lock().unwrap(); // panics "WouldBlock"This seem a rather new issue, in nightly-2017-03-01 it still worked. (May also work in few of the newer versions, haven't had time to try all of them.) |
This comment has been minimized.
This comment has been minimized.
|
Tried a few more nightly snapshots nightly-2017-03-04 is the first affected version, nightly-2017-03-03 works flawlessly. |
This comment has been minimized.
This comment has been minimized.
|
@pgerber Where can you find the nightly snapshots? I tried downloading them with rustup.rs, but it said older ones couldn't be found. |
This comment has been minimized.
This comment has been minimized.
|
@MJDSys This worked for me:
|
This comment has been minimized.
This comment has been minimized.
|
#40133 looks like the main diff. between the 2 versions. Self-assigning. |
arielb1
added
I-wrong
regression-from-stable-to-beta
labels
Mar 17, 2017
arielb1
self-assigned this
Mar 17, 2017
sfackler
added
the
T-compiler
label
Mar 17, 2017
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The first example is optimized out completely on my machine (using |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@arielb1 Did you run that on an armv7 machine, or on a x86(_64) machine? It seems something really weird is happening in the compiler. I'm working with a simpler example (see end of this post). A compiler on x86_64 produces a MIR representation that seems to make sense (dropping the option, and then the inner type). However with an armv7 compiler, it doesn't drop the option, but tries to drop the T (while inside the option). I'm not familiar with what the correct representation is, but that is the big difference I see on armv7. And just to be clear, I need to use a native compiler to see that difference. Cross-compiling the source file does not produce the difference. If it would help, I'll try to post the different outputs from MIR comparing before/after March 4 between x86_64 and armv7. I also don't think it's an issue in the MIR optimization passes, as when I dump the MIR using -Z dump-mir=all, that difference is always present. I'm doing all my testing right now with debug builds, but my initial testing before reporting the bug happened with both debug and release. New example: #[deny(warnings)]
struct T{}
impl Drop for T {
fn drop(&mut self) {
//println!("dropped");
panic!(false);
}
}
fn main() {
{
Some(T{});
}
} |
This comment has been minimized.
This comment has been minimized.
|
I am using an ARM compiler (rustc 1.17.0-nightly (b1e3176 2017-03-03) aka the Mar 4 nightly) in an x86_64 machine using qemu, which seems not to reproduce the bug. I don't have an ARM machine handy right now, |
This comment has been minimized.
This comment has been minimized.
|
Ah. The problem was that I was using the Correct "at-typeck" MIR looks like this:
Incorrect "at-typeck" MIR looks like this:
|
This comment has been minimized.
This comment has been minimized.
|
Looking at direct builder output: BAD:
GOOD:
|
This comment has been minimized.
This comment has been minimized.
|
debugging. It seems that after #40178, type contents is miscompiled somehow. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Reverting things did fix things for me. This is however, a miscompile, so problems are to be expected. |
This comment has been minimized.
This comment has been minimized.
|
Did you revert it on top of master, or on top of the nightly build from March 4th? |
This comment has been minimized.
This comment has been minimized.
|
On top of a559452 |
This comment has been minimized.
This comment has been minimized.
|
Looks like an LLVM bug, unless we have some "hidden" UB somewhere: For some reason, this IR:
Lowers the last call/or/select as
And a |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 Could you post the entire file, or give me steps to generate/investigate it locally? I'm new to playing with rustc's codebase and would like to take a deeper look/follow along at home. |
This comment has been minimized.
This comment has been minimized.
|
This looks like an LLVM bug, not a rustc bug. |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 That's fine, I'm just trying to learn more about the stack. If you have a reference for how you got that, I'm happy to read that as well. |
petrochenkov
referenced this issue
Mar 22, 2017
Closed
RefCell::borrow_mut codegen broken on ARM #40738
This comment has been minimized.
This comment has been minimized.
|
Minified LLVM bug - will report to LLVM after seeing the status on 4.0:
|
This comment has been minimized.
This comment has been minimized.
|
Reported as http://bugs.llvm.org/show_bug.cgi?id=32379. |
brson
added
the
A-LLVM
label
Mar 23, 2017
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
MJDSys commentedMar 17, 2017
When running the program at: https://is.gd/XHVVMt on my Chromebook (an Asus C201p) with the latest nightly compiler, I get the following error (RUST_BACKTRACE=1):
This doesn't occur on the latest stable compiler, and started sometime around March 12. This doesn't happen on my AMD 64bit desktop, nor on playground. Both debug and release builds are affected.
Code:
(note the extra scopes don't affect the behaviour.)