bevy/crates/bevy_core/src
Nathan Ward cbfb456847 [bevy_core/bytes] Fix UB with accessing memory with incorrect alignment (#1966)
After running `bevy_core` through `miri`, errors were reported surrounding incorrect memory accesses within the `bytes` test suit. 

Specifically:
```
test bytes::tests::test_array_round_trip ... error: Undefined Behavior: accessing memory with alignment 1, but alignment 4 is required
   --> crates/bevy_core/src/bytes.rs:55:13
    |
55  |             (*ptr).clone()
    |             ^^^^^^ accessing memory with alignment 1, but alignment 4 is required
    |
```

and 

```
test bytes::tests::test_vec_bytes_round_trip ... error: Undefined Behavior: accessing memory with alignment 2, but alignment 4 is required
   --> /home/nward/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/raw.rs:95:14
    |
95  |     unsafe { &*ptr::slice_from_raw_parts(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 2, but alignment 4 is required
    |
```

Solution:

The solution is to use `slice::align_to` method to ensure correct alignment.
2021-04-20 21:04:08 +00:00
..
time Doctest improvments (#1937) 2021-04-16 19:13:08 +00:00
bytes.rs [bevy_core/bytes] Fix UB with accessing memory with incorrect alignment (#1966) 2021-04-20 21:04:08 +00:00
float_ord.rs format comments (#1612) 2021-03-11 00:27:30 +00:00
label.rs format comments (#1612) 2021-03-11 00:27:30 +00:00
lib.rs format comments (#1612) 2021-03-11 00:27:30 +00:00
name.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
task_pool_options.rs use std clamp instead of Bevy's (#1644) 2021-03-13 18:07:14 +00:00