-
Notifications
You must be signed in to change notification settings - Fork 352
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
Android: Added support for prctl handling thread names #3899
Conversation
Thanks for the PR! There's currently a bit of a queue and I have fairly little time, so it may take a bit until I can review this. (Or maybe someone else will pick up the review.) |
Sure, and meanwhile I will fix issues reported by the CI. A side question, I noticed that the repository doesn't use git hooks like the |
4dc0032
to
07b0070
Compare
Repos can't have git hooks. What exactly are you referring to? |
The main repo installs them on bootstrap: https://github.com/rust-lang/rust/blob/1a5a2240bc1b8cf0bcce7acb946c78d6493a4fd3/src/bootstrap/src/core/build_steps/setup.rs#L462. |
The equivalent for this repo would be a |
07b0070
to
2e03626
Compare
A script feature would be also fine for me. The key point is to have something which can be used to run the same stuff as in the CI but locally. That thing was implemented in |
To have CI check that your PR works, please change this line Line 157 in 18a8ab7
to something like
|
@RalfJung, I made changes almost like you requested, but I didn't move Another thing I still cannot finish is the test. I tried to run it locally, but it ends up with the following message:
Meanwhile these constants exist and I definitely can compile the code. |
From what I understand from the CI test error, Error: the compiler panicked
Error: you likely need to bless the tests with `./miri test --bless`
Error:
0: ui tests in tests/pass for aarch64-linux-android failed
1: tests failed
Location:
/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ui_test-0.26.5/src/lib.rs:357
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`
Caused by:
process didn't exit successfully: `/Users/runner/work/miri/miri/target/debug/deps/ui-0ba442cf755d06fa empty_main integer vec string btreemap hello hashmap heap_alloc align panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus pthread threadname --skip pthread_cond_timedwait` (exit status: 1)
Error: command exited with non-zero code `cargo +miri test --locked --all-features --manifest-path /Users/runner/work/miri/miri/./Cargo.toml -- empty_main integer vec string btreemap hello hashmap heap_alloc align panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus pthread threadname --skip pthread_cond_timedwait`: 1
error: test got exit status: 101, but expected 0
= note: the compiler panicked
error: actual output differed from expected
Execute `./miri test --bless` to update `tests/pass/concurrency/threadname.stderr` to the actual output
--- tests/pass/concurrency/threadname.stderr
+++ <stderr output>
+thread 'rustc' panicked at src/helpers.rs:LL:CC:
+failed to find required Rust item: ["libc", "PR_SET_NAME"] I guess it is because |
So, |
let pr_set_name = this.eval_libc_i32("PR_SET_NAME"); | ||
let pr_get_name = this.eval_libc_i32("PR_GET_NAME"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any more android target that doesn't support these two flags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the git history these constants were added in 2011, so I guess it's supported everywhere now.
That could take a while, so we shouldn't block on it. You can hard-code the numbers for now and leave a FIXME pointing to the libc PR. |
☔ The latest upstream changes (presumably #3913) made this pull request unmergeable. Please resolve the merge conflicts. |
@RalfJung, I need a bit of help to finish this pull request. I run the
The return types both for #[cfg(target_os = "android")]
pub fn set_name(name: &CStr) {
const PR_SET_NAME: libc::c_int = 15;
unsafe {
libc::prctl(
PR_SET_NAME,
name.as_ptr(),
0 as libc::c_ulong,
0 as libc::c_ulong,
0 as libc::c_ulong,
);
}
} So, I'm a bit lost. What the compiler expects to be 8-bytes long? |
ed2aec0
to
a307230
Compare
☔ The latest upstream changes (presumably #3918) made this pull request unmergeable. Please resolve the merge conflicts. |
id if id == pr_set_name => { | ||
check_args_len("'PR_SET_NAME' prctl", args, 2)?; | ||
|
||
let tid = this.linux_gettid()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maintainers look busy, and I am waiting for review too, so I might as well help with this ;)
The problem seems to be in this line, it works with let tid = this.pthread_self()?;
.
The test report UB because of the size mismatch in this line:
Line 75 in bf0801d
let thread = thread.to_int(this.libc_ty_layout("pthread_t").size)?; |
9a3563b
to
8b4e661
Compare
@rustbot author |
☔ The latest upstream changes (presumably #3953) made this pull request unmergeable. Please resolve the merge conflicts. |
All right I think all the other cleanup is done. :D So after a rebase + squash this PR should be only adding the new shims, and extend the threadname test accordingly. |
9752f15
to
4f34ee1
Compare
☔ The latest upstream changes (presumably #3978) made this pull request unmergeable. Please resolve the merge conflicts. |
7bc3983
to
228c531
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rustbot author
Just a few hundred comments more and that pull request can be a new "legend" in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the last round. :)
Please squash (with get rebase --keep-base
) after resolving the last two comments.
Awesome, now please just squash (with |
f7cd0fa
to
4f79c0e
Compare
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
Addresses the first part of #3618.