Skip to content

Commit 3221268

Browse files
committed
Segfault reproducer for rust-lang/rust#107261
0 parents  commit 3221268

File tree

9 files changed

+492
-0
lines changed

9 files changed

+492
-0
lines changed

.cargo/config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[build]
2+
target = "avr-atmega32u4.json"
3+
rustflags = ["--emit=llvm-bc"]
4+
5+
[unstable]
6+
build-std = ["core"]
7+
8+
[env]
9+
AVR_CPU_FREQUENCY_HZ = "16_000_000"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

Cargo.lock

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "worduino-avr"
3+
version = "0.1.0"
4+
authors = ["Gergő ÉRDI <gergo@erdi.hu>"]
5+
6+
[dependencies]
7+
avr-config = "2.0.1"
8+
avr-std-stub = "1.0"
9+
worduino-engine = { path = "worduino-engine" }
10+
11+
[profile.release]
12+
lto = true

avr-atmega32u4.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"arch": "avr",
3+
"cpu": "atmega32u4",
4+
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
5+
"env": "",
6+
"executables": true,
7+
"linker": "avr-gcc",
8+
"linker-flavor": "gcc",
9+
"linker-is-gnu": true,
10+
"llvm-target": "avr-unknown-unknown",
11+
"os": "unknown",
12+
"position-independent-executables": false,
13+
"exe-suffix": ".elf",
14+
"eh-frame-header": false,
15+
"pre-link-args": {
16+
"gcc": [
17+
"-Os",
18+
"-mmcu=atmega32u4"
19+
]
20+
},
21+
"late-link-args": {
22+
"gcc": [
23+
"-lc",
24+
"-lgcc"
25+
]
26+
},
27+
"target-c-int-width": "16",
28+
"target-endian": "little",
29+
"target-pointer-width": "16",
30+
"vendor": "unknown"
31+
}

src/main.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#![feature(abi_avr_interrupt)]
2+
#![feature(core_intrinsics)]
3+
#![feature(asm_experimental_arch)]
4+
5+
#![no_std]
6+
#![no_main]
7+
8+
extern crate avr_std_stub;
9+
extern crate worduino_engine as worduino;
10+
11+
use worduino::*;
12+
13+
struct ArduboyPeripherals {
14+
pub framebuffer: [[u8; SCREEN_WIDTH as usize]; SCREEN_HEIGHT as usize / 8],
15+
}
16+
17+
impl ArduboyPeripherals {
18+
fn new() -> ArduboyPeripherals {
19+
ArduboyPeripherals {
20+
framebuffer: [[0; SCREEN_WIDTH as usize]; SCREEN_HEIGHT as usize / 8],
21+
}
22+
}
23+
}
24+
25+
impl Peripherals for ArduboyPeripherals {
26+
fn get_button(&self) -> bool {
27+
false
28+
}
29+
30+
fn get_stripe(&self, x: u8, stripe: u8) -> u8 {
31+
0x00
32+
}
33+
34+
fn set_stripe(&mut self, x: u8, stripe: u8, val: u8) {
35+
self.framebuffer[stripe as usize][x as usize] = val;
36+
}
37+
}
38+
39+
#[no_mangle]
40+
pub extern fn main() {
41+
let peripherals = ArduboyPeripherals::new();
42+
let mut engine = Engine::new(peripherals);
43+
44+
loop {
45+
engine.step();
46+
}
47+
}

worduino-engine/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

worduino-engine/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "worduino-engine"
3+
version = "0.1.0"
4+
authors = ["Gergő ÉRDI <gergo@erdi.hu>"]
5+
6+
[dependencies]
7+
avr-progmem = { version = "0.3.2", default-features = false, features = ["unsize"] }

0 commit comments

Comments
 (0)