Skip to content

Fix possible regression issue caused by ProposeWaitEmptyBlockTimer #1774

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

Merged
merged 1 commit into from
Sep 18, 2019

Conversation

foriequal0
Copy link
Contributor

Possible scenario:

  • Schedule timeout for ProposeWaitEmptyBlockTimer on height: n
  • On timeout, timer loop queues a call to Tendermint::on_timeout on the
    timer worker
  • Blocks are imported at the same time with the timeout.
    • Block importer holds lock for Tendermint, calls new_blocks
  • The worker checks whether it is cancelled, but it is not cancelled yet.
    • The worker waits for the lock.
  • several move_to_height, move_to_step are called by new_blocks
    • height is not n anymore.
    • move_to_step clears timer, but the check is already passed and the
      worker waits for the lock.
    • It finally releases the lock.
  • The waiting worker calls Tendermint::on_timeout and the timeout for
    ProposeWaitEmptyBlockTimer calls move_to_step(Prevote)
    • The timeout was set for the height n, but the code in the timeout
      reads changed height.

Possible scenario:
* Schedule timeout for `ProposeWaitEmptyBlockTimer` on height: n
* On timeout, timer loop queues a call to `Tendermint::on_timeout` on the
timer worker
* Blocks are imported at the same time with the timeout.
  * Block importer holds lock for Tendermint, calls `new_blocks`
* The worker checks whether it is cancelled, but it is not cancelled yet.
  * The worker waits for the lock.
* several `move_to_height`, `move_to_step` are called by new_blocks
  * height is not n anymore.
  * `move_to_step` clears timer, but the check is already passed and the
worker waits for the lock.
  * It finally releases the lock.
* The waiting worker calls Tendermint::on_timeout and the timeout for
`ProposeWaitEmptyBlockTimer` calls `move_to_step(Prevote)`
  * The timeout was set for the height n, but the code in the timeout
reads changed height.
@foriequal0 foriequal0 added the bug Something isn't working label Sep 18, 2019
@mergify mergify bot merged commit 96f7f94 into CodeChain-io:master Sep 18, 2019
@foriequal0 foriequal0 deleted the fix/prevote-reentry branch September 26, 2019 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants