-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Segmentation fault when calling set_thread_priority_and_policy
#41
Comments
Thank you for reporting an issue! What is the stack trace? Signal code? In my opinion, if it works somewhere else, when only the architecture is changed, no segfaults should happen as well and no different behaviour should be introduced. This is an API with a well-defined interface and behaviour. Regarding the different thread ids, regardless of the id, the implementation shouldn't do anything else except for returning an error code like The reason I am telling all of this is that I suspect a bug might be in the pthread/kernel code, which, for some reason, has way too different branches for these two architectures. And may I ask where did you find the information about passing |
Here's what I get from gdb. Let me know how I can provide more detail, I am not experienced in C.
Regarding setting Line 879 in 1135f2e
thread_native_id() works for Fifo but fails for Deadline policy with Os Error 3. But perhaps this should be a separate issue/discussion.
|
There is an assertion that it is valid, meaning it is positive in this case. Where did you get the information that it should be |
Regarding the thread id being set to 0: the test linked in the previous reply sets the thread id to zero with the comment
|
Indeed! But I am, unfortunately, not responsible for the logic in the other libraries (in the context of this project). I might take a look at the implementation of your libc later, but cannot guarantee. The code you posted should never lead to a crash, and it doesn't lead to it in the Rust part, so the crate doesn't do anything wrong here, I think. Do you think it does? Thanks for the documentation link about "zero", I somehow overlooked it. |
I agree about the seg fault not being the responsibility of this crate indeed. |
Okay, I see where your confusion comes from. For the deadline policy we use the So, if I may, you read the documentation page of one thing and applied its logic to another, completely different function with different arguments and types. :-)
Yes, we can have special checks for the policy and the passed thread id, as the code branches there for making either a syscall or a call to the |
The following example code yields a segmentation fault on an aarch64 Linux machine. I confirmed that the segfault occurs on the
unsafe
execution oflibc::pthread_setschedparam
.The code succeeds on an x86 machine.
Note also that
set_thread_priority_and_policy
has varying requirements for its ThreadId, which depend on the type of policy passed: for setting deadline on the current thread, 0 should be used as the id, whilethread_native_id()
should be used when setting a thread to the deadline policy. This should be documented or changed to avoid confusion, in my opinion.The text was updated successfully, but these errors were encountered: