rust-lang / backtrace-rs

Backtraces in Rust
https://docs.rs/backtrace
Other
537 stars 246 forks source link

`dl_iterate_phdr` assumes GNU/Linux #659

Closed workingjubilee closed 2 months ago

workingjubilee commented 2 months ago

Only GNU/Linux guarantees:

This doesn't seem to be guaranteed to be true, even on other flavors of Linux, which may have a sense of humor, e.g. musl's choices in the static linkage case:

        info.dlpi_addr  = base;
    info.dlpi_name  = "/proc/self/exe";
    info.dlpi_phdr  = (void *)aux[AT_PHDR];
    info.dlpi_phnum = aux[AT_PHNUM];
    info.dlpi_adds  = 0;
    info.dlpi_subs  = 0;
    if (tls_phdr) {
        info.dlpi_tls_modid = 1;
        info.dlpi_tls_data = __tls_get_addr((tls_mod_off_t[]){1,0});
    } else {
        info.dlpi_tls_modid = 0;
        info.dlpi_tls_data = 0;
    }
    return (callback)(&info, sizeof (info), data);
workingjubilee commented 2 months ago

See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199943