mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Under some conditions, a microtask would be executed for a context that was
already deinit'd, resulting in various use-after-free.
The culprit appears to be WASM compilation being placed in the microtask queue
(by a user-script) and then resolved at some point in the future. We guard the
microtask queue by a context.shutting_down boolean, but v8 doesn't know anything
about this flag. The fact is that, microtasks are tied to an isolate, not a
context.
This commit introduces a number of changes:
1 - It follows 309f254c2c and stores the zig Context inside of an embedder field. This
ensures v8 doesn't consider this when GC'ing, which _could_ extend the
lifetime of the v8::Context beyond what we expect
2 - Most significantly, it introduces per-context microtasks queues. Each
context gets its own queue. This makes cleanup much simpler and reduces the
chance of microtasks outliving the context
3 - pumpMessageLoop is called on context.deinit, this helps to ensure that any
tasks v8 has for our context are processed (e.g. wasm compilation) before
shtudown
4 - The order of context shutdown is important, we notify the isolate of the
context destruction first, then pump the message loop and finally destroy
the context's message loop.
Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/151
68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: "Browsercore install"
|
|
description: "Install deps for the project browsercore"
|
|
|
|
inputs:
|
|
arch:
|
|
description: 'CPU arch used to select the v8 lib'
|
|
required: false
|
|
default: 'x86_64'
|
|
os:
|
|
description: 'OS used to select the v8 lib'
|
|
required: false
|
|
default: 'linux'
|
|
zig-v8:
|
|
description: 'zig v8 version to install'
|
|
required: false
|
|
default: 'v0.3.0'
|
|
v8:
|
|
description: 'v8 version to install'
|
|
required: false
|
|
default: '14.0.365.4'
|
|
cache-dir:
|
|
description: 'cache dir to use'
|
|
required: false
|
|
default: '~/.cache'
|
|
debug:
|
|
description: 'enable v8 pre-built debug version, only available for linux x86_64'
|
|
required: false
|
|
default: 'false'
|
|
|
|
runs:
|
|
using: "composite"
|
|
|
|
steps:
|
|
- name: Install apt deps
|
|
if: ${{ inputs.os == 'linux' }}
|
|
shell: bash
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y wget xz-utils ca-certificates clang make git
|
|
|
|
# Zig version used from the `minimum_zig_version` field in build.zig.zon
|
|
- uses: mlugg/setup-zig@v2
|
|
|
|
# Rust Toolchain for html5ever
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache v8
|
|
id: cache-v8
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-v8
|
|
with:
|
|
path: ${{ inputs.cache-dir }}/v8
|
|
key: libc_v8_${{ inputs.v8 }}_${{ inputs.os }}_${{ inputs.arch }}_${{ inputs.zig-v8 }}${{inputs.debug == 'true' && '_debug' || '' }}.a
|
|
|
|
- if: ${{ steps.cache-v8.outputs.cache-hit != 'true' }}
|
|
shell: bash
|
|
run: |
|
|
mkdir -p ${{ inputs.cache-dir }}/v8
|
|
|
|
wget -O ${{ inputs.cache-dir }}/v8/libc_v8.a https://github.com/lightpanda-io/zig-v8-fork/releases/download/${{ inputs.zig-v8 }}/libc_v8_${{ inputs.v8 }}_${{ inputs.os }}_${{ inputs.arch }}${{inputs.debug == 'true' && '_debug' || '' }}.a
|
|
|
|
- name: install v8
|
|
shell: bash
|
|
run: |
|
|
mkdir -p v8
|
|
ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a v8/libc_v8${{inputs.debug == 'true' && '_debug' || '' }}.a
|