Skip to content

Conversation

@karlseguin
Copy link
Collaborator

When EventTargetTBase is used, we pass the container as the target to libdom. This is not safe, as libdom is expecting an event_target. We see, for example that when _dom_event_get_current_target is called, the refcnt is increased. This works if the current_target is a valid event_target, but if it's a Zig instance (like the Window) ... we're just altering some bits of the window instance.

This attempts to add a dummy target to EventTargetTBase which can acts as a real event_targt in place of the Zig instance.

When EventTargetTBase is used, we pass the container as the target to libdom.
This is not safe, as libdom is expecting an event_target. We see, for example
that when _dom_event_get_current_target is called, the refcnt is increased.
This works if the current_target is a valid event_target, but if it's a
Zig instance (like the Window) ... we're just altering some bits of the
window instance.

This attempts to add a dummy target to EventTargetTBase which can acts as a
real event_targt in place of the Zig instance.
@karlseguin karlseguin requested a review from krichprollsch June 18, 2025 06:53
Mimic a dom_node by adding the refcnt field right after the vtable
pointer.
@krichprollsch krichprollsch merged commit c1ffe7f into main Jun 18, 2025
11 checks passed
@krichprollsch krichprollsch deleted the zig_event_target_fix branch June 18, 2025 15:26
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants