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

Use dl_iterate_phdr on Haiku #699

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Feb 8, 2025

An implementation or dl_iterate_phdr was added to Haiku in haiku/haiku@908107a a little over a year after Haiku support got added to backtrace-rs.

An implementation or dl_iterate_phdr was added to Haiku a little over a
year after Haiku support got added to backtrace-rs.
Haiku's dynamic linker (/system/runtime_loader) doesn't support getting
directly invoked rather than going through PT_INTERP.
Repos often delete package versions soon after a new version is
available. If the package list still references an old version, apt will
error when trying to install the package.
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 8, 2025

cc @nielx

@workingjubilee
Copy link
Member

We don't have an official Haiku maintainer enrolled it seems, so if either @waddlesplash or @trungnt2910 (or whoever else, basically) think this is good then I'm happy to ship it.

@waddlesplash
Copy link

Should be fine; internally dl_iterate_phdr is implemented using get_next_image_info anyway. You lose the "length" information since the phdr structs don't provide this, but that's the same as on other OSes.

Also note that dl_iterate_phdr is in libbsd.so, the "BSD-related APIs" library (as opposed to libroot.so, the C library, API primitives & syscalls, etc. where get_next_image_info lives.) I think Rust on Haiku always links in libbsd.so anyway, so that doesn't really matter in the end.

@waddlesplash
Copy link

Hmm, I just looked at the code some more, and it appears that when dl_iterate_phdr is used, "gimli" tries to read /proc/self/maps to determine size information? Haiku doesn't have /proc/ at all, so that won't work. There are APIs to get the mappings/"areas" information for the current process, but they're Haiku-specific. If this is needed, in the end it may just make sense to keep the Haiku-specific get_next_image_info which provides map size information directly instead of using dl_iterate_phdr (and perhaps add a comment indicating this.)

@nielx
Copy link
Contributor

nielx commented Feb 14, 2025

Agreed with @waddlesplash here.

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 14, 2025

Haiku doesn't have /proc/ at all, so that won't work.

Huh, why didn't the backtrace-rs tests fail on Haiku with this PR if that is the case?

@nielx
Copy link
Contributor

nielx commented Feb 15, 2025

Haiku doesn't have /proc/ at all, so that won't work.

Huh, why didn't the backtrace-rs tests fail on Haiku with this PR if that is the case?

In the PR you are disabling one of the tests. How did it fail?
What other testing have you done? The changes will affect finding symbols in libraries. Have you done a more elaborate test where you try to get a stack trace from a library?

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 15, 2025

In the PR you are disabling one of the tests. How did it fail?

This test reads the dynamic linker from the test executable and then invokes the dynamic linker as executable with the teste executable as argument. I got confirmation from @waddlesplash that this is fundamentally unsupported on Haiku.

The changes will affect finding symbols in libraries.

Ah, could well be that there are simply no tests for resolving symbols in shared libraries.

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

Successfully merging this pull request may close these issues.

4 participants