Skip to content

x86_64-unknown-linux-musl + profiling = segmentation fault #146

@howardjohn

Description

@howardjohn

We see that any binaries built with Jemalloc with profiling enabled, on the x86_64-unknown-linux-musl target, immediate segfaults:

$ cargo run --target x86_64-unknown-linux-musl
   Compiling new v0.1.0 (/tmp/tmp.iluiyelSHz/new)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/x86_64-unknown-linux-musl/debug/new`
zsh: segmentation fault  cargo run --target x86_64-unknown-linux-musl

Reproducer:

[package]
name = "new"
version = "0.1.0"
edition = "2021"

[dependencies]
tikv-jemallocator = { version = "0.6.0", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

#[allow(non_upper_case_globals)]
#[unsafe(export_name = "malloc_conf")]
pub static malloc_conf: &[u8] = b"prof:true\0";

fn main() {
    println!("Hello, world!");
}

This was tested with rustc 1.83 and 1.90; both saw the same. Other fields in malloc_conf do not trigger the segfault, which leads me to believe it is specific to profiling and not general malloc_conf usage.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions