Rust-GPU / Rust-GPU/rust-gpu

[Migrated] `core::mem::swap` used to work, then broke (and later accidentally got unbroken again).

Open
#117 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/804
Old labels: t: bug,a: rust-lang,t: external,s: qptr may fix
Originally creatd by hatoo on 2021-11-21T13:05:53Z


Expected Behaviour

Codes that uses core::mem::swap

#![cfg_attr(
    target_arch = "spirv",
    no_std,
    feature(register_attr),
    register_attr(spirv)
)]

#[cfg(not(target_arch = "spirv"))]
use spirv_std::macros::spirv;

use spirv_std as _;

#[spirv(vertex)]
pub fn test_vs() {
    let mut x1 = 0.0f32;
    let mut x2 = 1.0f32;

    core::mem::swap(&mut x1, &mut x2);
}

will compile. it's OK in previous version at least b9867d0e84d29d6e60ad62427f453b4829abda56.

Example & Steps To Reproduce
  1. Clone https://github.com/hatoo/rust-gpu-issue/tree/swap-fail (note: swap-fail branch)
  2. cargo build and error
> cargo build
   Compiling builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)
error: failed to run custom build command for `builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)`

Caused by:
  process didn't exit successfully: `C:\Users\hato2\Desktop\rust-gpu-issue\target\debug\build\builder-caf084bc583adeed\build-script-build` (exit code: 1)
  --- stderr
     Compiling shader v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\shader)
  error: Cannot memcpy dynamically sized data
      --> C:\Users\hato2\.rustup\toolchains\nightly-2021-10-26-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\intrinsics.rs:2057:14
       |
  2057 |     unsafe { copy_nonoverlapping(src, dst, count) }
       |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  error: could not compile `shader` due to previous error
  Error: BuildFailed

It's OK in the previous version. Please see https://github.com/hatoo/rust-gpu-issue/tree/swap-succ.

System Info

  • Rust: rustc 1.58.0-nightly (29b124802 2021-10-25)
  • OS: Windows 11
  • GPU: RTX2080ti
  • SPIR-V: SPIRV-Tools v2021.3 v2021.3

Backtrace

Backtrace

<backtrace>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the linked rust-gpu-issue swap-fail branch using cargo build, then compare it with swap-succ and commit b9867d0e84d29d6e60ad62427f453b4829abda56. Start at core/src/intrinsics.rs:2057, where the Cannot memcpy dynamically sized data error is reported; done means the provided core::mem::swap shader builds successfully again.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.