Fix the size of the domain_id passed by tick thread to caml_init_domain_self#11550
Merged
xavierleroy merged 1 commit intoocaml:trunkfrom Sep 21, 2022
Merged
Conversation
xavierleroy
approved these changes
Sep 21, 2022
Contributor
xavierleroy
left a comment
There was a problem hiding this comment.
Obviously correct. Thanks for the detective work.
For those who wonder why this shows up on s390x but not on x86, say: s390x is big-endian, causing the 32-bit int tp end up in the 32 high bits of the 64-bit uintnat, then to be discarded as @Engil described.
xavierleroy
pushed a commit
that referenced
this pull request
Sep 21, 2022
(cherry picked from commit eccc311)
Contributor
|
Cherry-picked to 5.0 : 69a3e32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While investigating the s390x test suite failure at #11385, I found this error I introduced while porting the tick thread to Multicore.
The fix is pretty straightforward, and the deadlock we could see on the precheck run was caused by
caml_thread_tickassuming the wrong size fordomain_id(uintnatinstead ofint).The compiled code would then truncate it with a (64 <- 32) load, meaning that the tick thread would initialise itself to domain 0.
This would not lead to a crash, however the way we request the tick thread to stop is by setting an integer in a domain_id indexed array:
#define Tick_thread_stop tick_thread_stop[Caml_state->id]So if domain 1 starts up, the tick thread will see itself as being part of domain 0, and will not answer to a termination request, leading to a the main thread waiting on the join forever.
I am sorry for this mishap.