Skip to content

Safety of intrinsics #355

New issue

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

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

Already on GitHub? # to your account

Closed
fpoli opened this issue May 15, 2020 · 3 comments · Fixed by #452
Closed

Safety of intrinsics #355

fpoli opened this issue May 15, 2020 · 3 comments · Fixed by #452

Comments

@fpoli
Copy link

fpoli commented May 15, 2020

Shouldn't mem::__llvm_memcpy_element_unordered_atomic_1 and similar functions be marked as unsafe? The following program crashes with "Segmentation fault (core dumped)".

// compiler_builtins = "=0.1.23"

extern crate compiler_builtins;

fn main() {
    compiler_builtins::mem::__llvm_memcpy_element_unordered_atomic_1(
        std::ptr::null::<u128>() as *mut u8,
        std::ptr::null(),
        1
    );
}
@alexcrichton
Copy link
Member

Ah yeah this should be unsafe for sure, thanks for the report!

@LukasKalbertodt
Copy link
Member

LukasKalbertodt commented Jun 20, 2020

What exactly does "similar functions" mean? It seems like we should fix this issue sooner rather than later, but I unfortunately don't really know enough about this stuff to properly judge what should be unsafe and what not. I would guess that everything in mem should be unsafe, right?

@alexcrichton
Copy link
Member

I'd interpret it the same as Rust, where safe means "impossible to cause UB regardless of arguments".

These take a raw pointer and that's unsafe since you can manufacture pointers.

@Amanieu Amanieu linked a pull request Feb 6, 2022 that will close this issue
tgross35 added a commit to tgross35/compiler-builtins that referenced this issue Feb 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants