Skip to content

dladdr cannot leave dli_fname to be null #141239

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

Merged
merged 1 commit into from
May 19, 2025
Merged

Conversation

RalfJung
Copy link
Member

There are two places in the repo calling dladdr, and they are inconsistent wrt their assumption of whether the dli_fname field can be null. Let's make them consistent. I see nothing in the docs that allows it to be null, but just to be on the safe side let's make this an assertion so hopefully we get a report if that ever happens.

@rustbot
Copy link
Collaborator

rustbot commented May 19, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot
Copy link
Collaborator

rustbot commented May 19, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 19, 2025
@@ -92,8 +92,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn get_func_ptr_explicitly_from_lib(&mut self, link_name: Symbol) -> Option<CodePtr> {
let this = self.eval_context_mut();
// Try getting the function from the shared library.
// On windows `_lib_path` will be unused, hence the name starting with `_`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was outdated, the entire module does not even get built on Windows.

@RalfJung RalfJung mentioned this pull request May 19, 2025
8 tasks
@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented May 19, 2025

📌 Commit d22f53b has been approved by Noratrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 19, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang#140847 (coverage: Detect unused local file IDs to avoid an LLVM assertion)
 - rust-lang#141117 (opt-dist: fix deprecated BOLT -icf=1 option)
 - rust-lang#141225 (more ice tests)
 - rust-lang#141239 (dladdr cannot leave dli_fname to be null)
 - rust-lang#141242 (in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b86de53 into rust-lang:master May 19, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 19, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 19, 2025
Rollup merge of rust-lang#141239 - RalfJung:dladdr-fname, r=Noratrieb

dladdr cannot leave dli_fname to be null

There are two places in the repo calling `dladdr`, and they are inconsistent wrt their assumption of whether the `dli_fname` field can be null. Let's make them consistent. I see nothing in the docs that allows it to be null, but just to be on the safe side let's make this an assertion so hopefully we get a report if that ever happens.
if info.dli_fname.is_null() {
return Err("dladdr returned null pointer".into());
}
assert!(!info.dli_fname.is_null(), "the docs do not allow dladdr to be null");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "do not allow dli_fname to be null" ? as you pointed out, dladdr can return 0, and dli_sname can be null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants