Skip to content

Conversation

Keno
Copy link
Member

@Keno Keno commented Oct 1, 2021

Looks like #36929 got reverted. Not sure what happened there. Re-apply it to fix TSAN.

@Keno Keno requested a review from vtjnash October 1, 2021 07:19
@Keno Keno force-pushed the kf/fixtsanagain branch from 8aabc09 to b249b33 Compare October 1, 2021 07:36
Looks like #36929 got reverted
without comment. Not sure what happened there. Re-apply it to fix TSAN.
@Keno Keno force-pushed the kf/fixtsanagain branch from b249b33 to c9369ad Compare October 1, 2021 07:40
@Keno
Copy link
Member Author

Keno commented Oct 1, 2021

Will fix it in the morning.

@vtjnash
Copy link
Member

vtjnash commented Oct 1, 2021

In certain modes, we copy this state and expect to have certain properties. Need to look closer to see if if this is okay with all the various option combinations.

memcpy(&t->copy_stack_ctx, &ptls->copy_stack_ctx, sizeof(t->copy_stack_ctx) - sizeof(t->copy_stack_ctx.tsan_state));
else
memcpy(&t->ctx, &ptls->base_ctx, sizeof(t->ctx));
memcpy(&t->ctx, &ptls->base_ctx, sizeof(t->ctx) - sizeof(t->ctx.tsan_state));
Copy link
Member

@vtjnash vtjnash Oct 3, 2021

Choose a reason for hiding this comment

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

Suggested change
memcpy(&t->ctx, &ptls->base_ctx, sizeof(t->ctx) - sizeof(t->ctx.tsan_state));
memcpy(&t->ctx.uc_mcontext, &ptls->base_ctx.uc_mcontext, sizeof(t->ctx.uc_mcontext));

t->bufsz = 0;
if (always_copy_stacks)
memcpy(&t->copy_stack_ctx, &ptls->copy_stack_ctx, sizeof(t->copy_stack_ctx));
memcpy(&t->copy_stack_ctx, &ptls->copy_stack_ctx, sizeof(t->copy_stack_ctx) - sizeof(t->copy_stack_ctx.tsan_state));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
memcpy(&t->copy_stack_ctx, &ptls->copy_stack_ctx, sizeof(t->copy_stack_ctx) - sizeof(t->copy_stack_ctx.tsan_state));
memcpy(&t->copy_stack_ctx.uc_mcontext, &ptls->copy_stack_ctx.uc_mcontext, sizeof(t->copy_stack_ctx.uc_mcontext));

But I'm not sure if uc_mcontext is something C can deal with, or if it needed to be wrapped in a struct to be something that C could create access.

Copy link
Member

Choose a reason for hiding this comment

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

But note that this is in the COPY_STACKS code path, so currently we disable this code path entirely if TSAN is enabled

@vtjnash vtjnash closed this Oct 6, 2021
@vtjnash
Copy link
Member

vtjnash commented Oct 6, 2021

I will fix and update this, with other fixes

@DilumAluthge DilumAluthge deleted the kf/fixtsanagain branch October 26, 2021 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants