Skip to content
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

Fix race condition with preemption timers #307

Merged
merged 1 commit into from
Aug 21, 2018

Conversation

layus
Copy link
Member

@layus layus commented Aug 21, 2018

Fixes #305 and closes #284.

/cc @sjrd, @eregon Would you mind reviewing this ?

@layus layus force-pushed the fix-race-condition branch 3 times, most recently from f3cd970 to 09fc238 Compare August 21, 2018 12:39
@layus layus mentioned this pull request Aug 21, 2018
@eregon
Copy link
Member

eregon commented Aug 21, 2018

Is -fthread-sanitizer happy now?

@@ -50,7 +50,7 @@ BoostVM::BoostVM(BoostEnvironment& environment,
uuidGenerator(),
portClosed(false),
_asyncIONodeCount(0),
preemptionTimer(environment.io_service),
preemptionTimer(nullptr),
alarmTimer(environment.io_service),
Copy link
Member

Choose a reason for hiding this comment

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

What about this timer? Is it only accessed through this VM's thread?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It would be simpler to do the same for preemptionTimer, but then it would not be able to restart itself, and the restart should be done in the vm when the preemption flag is cleared. And it looks difficult because the vm is a real vm, while the other is a boostvm...

Copy link
Member

Choose a reason for hiding this comment

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

And it looks difficult because the vm is a real vm, while the other is a boostvm...

I think that just need adding one method in the interface between the two, but I don't remember the details. It would change semantics from "preempt every millisecond" to "preempt every millisecond+the time for VM to notice" though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly. And this works, so why bother ;-)

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

Nice work!
It looks good to me, but I am no Boost AsyncIO expert.

@layus layus merged commit e9cdf6b into mozart:master Aug 21, 2018
@layus layus removed the request for review from sjrd August 21, 2018 15:47
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.

Mozart2 hangs Segfault in the vm
2 participants