Closed
Description
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Key {
AltArrow(Arrow),
Arrow(Arrow),
Ctrl(char),
Char(char),
Esc,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Arrow { Left, Right, Up, Down }
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Event {
Key(Key),
String(String),
Resize,
Unknown(Vec<u8>),
}
static XTERM_SINGLE_BYTES : [(u8, Event); 5] =
[ (1, Event::Key(Key::Ctrl('a'))),
(5, Event::Key(Key::Ctrl('e'))),
(23, Event::Key(Key::Ctrl('w'))),
(11, Event::Key(Key::Ctrl('k'))),
(4, Event::Key(Key::Ctrl('d'))),
];
fn main() {
println!("{:?}", XTERM_SINGLE_BYTES);
}
(can be tested here: https://is.gd/EkJ3by)
When run with beta or nightly, this program segfaults.
I tried to simplify this a little bit, but my attempts either turned segfault into a stack overflow, or made it working. Here are some changes I've tried:
- I tried
[(u8, char)]
forXTERM_SINGLE_BYTES
and it worked fine. - I tried removing
Event::Key
s (e.g.[(u8, Key)]
) and it worked. - I removed some of the constructors from
Event
enum, most of the time the error turned into a stack overflow.
In my original program I'm iterating the array, and for the u8
part I'm getting random bytes instead of bytes I put in the array. I'm using rustc 1.13.0-nightly (70598e0 2016-09-03).
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
durka commentedon Sep 11, 2016
Minimized a bit:
This incorrectly prints
[(1, Key(0))]
.I wonder if it has something to do with the nullable pointer layout optimization, as the issue goes away if theVec
variant is removed.TimNN commentedon Sep 11, 2016
With
-Z orbit
, this was introduced betweennightly-2016-05-08
andnightly-2016-05-09
(Changes).(Edit: I missed a nightly in the original version of this comment.)
osa1 commentedon Sep 11, 2016
Thanks @TimNN, as a workaround until this is fixed I switched to nightly-2016-05-08 and it works nicely.
durka commentedon Sep 11, 2016
In that case I'm suspicious of #33130 cc @eddyb
TimNN commentedon Sep 11, 2016
The
Vec
is not necessary to reproduce,as long as the types wrapped are of different sizes.
Also, I can reproduce this only as long as the size of the integer used in the static is smaller than than the size of the larger "wrapped" integer (in this case, the wrapped integer is
i16
, so onlyi8
andu8
will reproduce this).arielb1 commentedon Sep 11, 2016
Looks like missing alignment:
nagisa commentedon Sep 11, 2016
@arielb1 where did you get this? With original test case on play.rlo has
align 8
for all stable, beta and nightly, which seems to be the expected value?arielb1 commentedon Sep 11, 2016
The
u16
variant by @TimNN. The problem is not thealign 2
but the{ i8, { i8, [3 x i8] } }
use `adt::trans_const` when translating constant closures and tuples
adt::trans_const
when translating constant closures and tuples #36406Auto merge of #36406 - arielb1:constant-padding, r=eddyb
5 remaining items