Skip to content

Bug Report: Box::from_raw does not trigger segmentation fault in VSCode runnable #19470

@Nahida7

Description

@Nahida7

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer version: 0.3.2353-standalone (37acea8 2025-03-23)

rustc version: (eg. output of rustc -V)

rustc 1.85.1 (4eb161250 2025-03-15)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

VSCode (rust-lang.rust-analyzer 0.3.2353)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

fn main() {
    // try to create a Box from a invalid pointer
    let _ = unsafe {
        let mut ptr: *mut i32 = std::ptr::null_mut();
        ptr = ptr.add(10usize);
        Box::from_raw(ptr);
    };
}

Observed behavior:

When running cargo run from the terminal, the program correctly triggers a segmentation fault.

Image

However, when running the same code using VSCode’s "Run" button (runnable feature), it does not trigger a segmentation fault.

Image

Expected behavior:

The behavior should be consistent: running the code in VSCode should also trigger a segmentation fault, just like when using cargo run in the terminal.

Additional context:

It seems that the VSCode runnable feature might be handling process crashes differently. Would appreciate insights on whether this is expected behavior or a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: support questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions