-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
TSan should handle Effect.Unhandled
correctly
#12593
Conversation
14e1d96
to
19b34b7
Compare
I don't understand the details, but the code does not look very nice: 100% of the additions to the C code are new weird corner cases. Is there a simpler way to do this?
What if we did not bypass |
0de0f14
to
5deb507
Compare
We were dubious initially, but it turns out that yes, we found a smaller fix by doing Note: for this to work, we modify |
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 indeed agree that the new version is nicer. I don't 100% follow the details of how the show stack winding/unwinding work in the new model vs. the older one, but I trust the combination of you and the testsuite to get it correct. I reviewed that this PR does not break anything outside TSan mode. Approved.
runtime/amd64.S
Outdated
@@ -735,6 +735,7 @@ LBL(caml_c_call): | |||
/* Save non-callee-saved registers %rax and %xmm0 before C call */ | |||
pushq %rax; CFI_ADJUST(8); | |||
subq $16, %rsp; CFI_ADJUST(16); | |||
/* Save %xmm0 before C call */ |
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.
This line looks a bit redundant with the comment just above.
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.
Fixed in latest version (I also squashed the history)
Co-authored-by: Olivier Nicole <olivier@chnik.fr>
95ac967
to
9a7e6c2
Compare
TSan wasn't handling correctly the case where an effect was
perform
ed without a matching effect handler, as noted in #12535 (comment).There were two possible behaviours:
perform
ed from a computation, the lastcaml_reperform
would reconnect thecurrent_stack
to its parent stack (the main fiber) too early, causingcaml_tsan_entry_on_resume
to call__tsan_func_entry
on too many functions.The proposed fix introduces a
struct stack_info const* limit
argument tocaml_tsan_entry_on_resume
, which is set to the previous fiber bycaml_perform
, preventing the unnecessary calls to__tsan_func_entry
.caml_tsan_entry_on_resume
was called unconditionally, althoughcaml_tsan_exit_on_perform
was bypassed because the fiber has no parent stack.In the proposed fix, the limit set to
Caml_state(current_stack)
bycaml_perform
prevents again the unnecessary calls to__tsan_func_entry
.When a continuation is
resume
d, thelimit
forcaml_tsan_entry_on_resume
is set toNULL
meaning that we expect to unwind the stack of all the fibers from the continuation.We have also added a test to the TSan testsuite, to validate that the backtrace given by TSan is correct in the 2 cases described above.