Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment fault when compiling assembly #67511

Closed
SchrodingerZhu opened this issue Dec 22, 2019 · 1 comment
Closed

Segment fault when compiling assembly #67511

SchrodingerZhu opened this issue Dec 22, 2019 · 1 comment

Comments

@SchrodingerZhu
Copy link

Compile a asm block with =m will lead the compiler to seg fault. I think if there is any error with the code, the compiler should indicate it rather than run into segment fault.

pub unsafe extern "C" fn atomic_and_u64(p: *mut u64, v: u64) -> u64 {
    asm!("lock ; andq $1, $0" : "=m"(*p) : "r"(v) : "memory");
    *p
}

Error

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name toylibc src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C panic=abort -C debuginfo=2 -C metadata=f536773699f0f74f -C extra-filename=-f536773699f0f74f --out-dir /home/schrodinger/CLionProject/toylibc/target/debug/deps -C incremental=/home/schrodinger/CLionProject/toylibc/target/debug/incremental -L dependency=/home/schrodinger/CLionProject/toylibc/target/debug/deps --extern lazy_static=/home/schrodinger/CLionProject/toylibc/target/debug/deps/liblazy_static-b4fa3bf214a3db33.rmeta --extern libm=/home/schrodinger/CLionProject/toylibc/target/debug/deps/liblibm-9d192941e1060f4a.rmeta --extern num_complex=/home/schrodinger/CLionProject/toylibc/target/debug/deps/libnum_complex-8efc7ec6cfc104f8.rmeta --extern packed_simd=/home/schrodinger/CLionProject/toylibc/target/debug/deps/libpacked_simd-91b90749ee6f08f0.rmeta --extern rand=/home/schrodinger/CLionProject/toylibc/target/debug/deps/librand-25733e87e78583f1.rmeta --extern rusty_asm=/home/schrodinger/CLionProject/toylibc/target/debug/deps/librusty_asm-107b2a2a8d9cb95d.so --extern simdeez=/home/schrodinger/CLionProject/toylibc/target/debug/deps/libsimdeez-628e9dc7fee60165.rmeta --extern spin=/home/schrodinger/CLionProject/toylibc/target/debug/deps/libspin-2a6e9c378b3e2966.rmeta --extern syscalls=/home/schrodinger/CLionProject/toylibc/target/debug/deps/libsyscalls-85e15f6b741aa697.rmeta` (signal: 11, SIGSEGV: invalid memory reference)

@csmoe
Copy link
Member

csmoe commented Dec 22, 2019

Duplicate of #29722 (comment)

@csmoe csmoe marked this as a duplicate of #29722 Dec 22, 2019
@csmoe csmoe closed this as completed Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants