Skip to content

fix(runtime): Crashes after destroying a worker runtime #1213

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 5 commits into from
Oct 21, 2019

Conversation

mbektchiev
Copy link
Contributor

  • Check for destroyed TNSRuntime and handle gracefully in dealloc. Sometimes
    native objects having JS counterparts could live longer than their respective TNSRuntimes
    (e.g. JS callbacks that have been subscribed for events from NSNotificationCenter)

  • Add RELEASE_ASSERTs for alive TNSRuntime in all places in the code where
    this is expected.

  • Allow creation of an ObjCWrapperObject without an alive TNSRuntime. This
    is needed when the native object needs to be accessed from another VM (e.g.
    accessing the handler to destroy it from the main (notifications producer) thread
    when the worker has already exited)

  • [webkit] Guard against destroyed and nullptr VM's in locking primitives

  • Keep VM alive as long as there are objects referring it

  • Add strong references to VM from blocks and native adapters for JS objects

  • Invoke C++ destructor in disposeBlock instead of the explicit clearing its
    member(s)

  • Keep worker thread alive as long as the VM is in use

  • Add tests for crashes and leaked runtimes

PR Checklist

refs #1163

There are optimizations which skip `configure` and `autoreconf` steps,
but it's good to leave some traces in the build output in case these lead
to obscure failures.
* Check for destroyed `TNSRuntime` and handle gracefully in `dealloc`. Sometimes
native objects having JS counterparts could live longer than their respective `TNSRuntimes`
(e.g. JS callbacks that have been subscribed for events from `NSNotificationCenter`)

* Add `RELEASE_ASSERT`s for alive `TNSRuntime` in all places in the code where
this is expected.

* Allow creation of an `ObjCWrapperObject` without an alive `TNSRuntime`. This
is needed when the native object needs to be accessed from another VM (e.g.
accessing the handler to destroy it from the main (notifications producer) thread
when the worker has already exited)

* [webkit] Guard against destroyed and `nullptr` VM's in locking primitives
* Add strong references to VM from blocks and native adapters for JS objects
* Invoke C++ destructor in `disposeBlock` instead of the explicit clearing its
member(s)
@mbektchiev mbektchiev self-assigned this Oct 17, 2019
@cla-bot cla-bot bot added the cla: yes label Oct 17, 2019
@mbektchiev mbektchiev added this to the 6.3.0 milestone Oct 17, 2019
* Keep worker thread alive as long as the VM is in use
* Add tests for crashes and leaked runtimes
@mbektchiev mbektchiev force-pushed the bektchiev/fix-workers-destroy-crash branch from 679af62 to 2d41cb2 Compare October 18, 2019 06:49
@mbektchiev mbektchiev merged commit 0ee2ba0 into master Oct 21, 2019
@mbektchiev mbektchiev deleted the bektchiev/fix-workers-destroy-crash branch October 21, 2019 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants