Skip to content

During a jump, handle interrupts before updating the opline #7642

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

Closed
wants to merge 1 commit into from

Conversation

tstarling
Copy link
Contributor

If an exception is thrown by the interrupt handler after updating the
opline, the result variable will be freed even though it has not been
written to. So:

  • In jump handlers, check for an interrupt before doing anything else. If an interrupt is handled, return to the VM. The jump handler will then be re-entered if there was no exception.
  • In smart branches, check for EG(vm_interrupt) before checking for EG(exception), so that exception handling from the ordinary and interrupt cases can be combined. Exceptions are handled before the return value is populated, but the existing hack stops it from crashing.
  • Remove the interrupt check from ZEND_VM_ENTER_EX, for consistency with the other variants. Checking for an interrupt here seems to be unnecessary.
  • In the goto and switch VM kinds, disable interrupt handling in smart branches. Maybe Dmitry can figure out how to make it work.

The JIT is affected and is not fixed here.

Partially fixes bug #81610.

If an exception is thrown by the interrupt handler after updating the
opline, the result variable will be freed even though it has not been
written to. So:

* In jump handlers, check for an interrupt before doing anything else.
  If an interrupt is handled, return to the VM. The jump handler will
  then be re-entered if there was no exception.
* In smart branches, check for EG(vm_interrupt) before checking for
  EG(exception), so that exception handling from the ordinary and
  interrupt cases can be combined. Exceptions are handled before the
  return value is populated, but the existing hack stops it from
  crashing.
* Remove the interrupt check from ZEND_VM_ENTER_EX, for consistency with
  the other variants. Checking for an interrupt here seems to be
  unnecessary.
* In the goto and switch VM kinds, disable interrupt handling in smart
  branches. Maybe Dmitry can figure out how to make it work.

The JIT is affected and is not fixed here.

Partially fixes bug #81610.
@dstogov
Copy link
Member

dstogov commented Nov 11, 2021

Did you see this #7624 ?

@dstogov
Copy link
Member

dstogov commented Nov 11, 2021

The bug is partially fixed in PHP-8.0 and above by fa0b84a and 5380b41

@tstarling
Copy link
Contributor Author

Did you see this #7624 ?

No I hadn't. I'll test it.

@tstarling
Copy link
Contributor Author

The merged fixes by @dstogov work for me.

@tstarling tstarling closed this Nov 12, 2021
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