Skip to content

Conversation

@karlseguin
Copy link
Collaborator

An empty struct will share the same address as its sibling (1) which will cause an collision in the identity map.

(1) - This depends on Zig's non-guaranteed layout, so the collision might not be with its sibling, but rather some other [seemingly random] field.

An empty struct will share the same address as its sibling (1) which will cause
an collision in the identity map.

(1) - This depends on Zig's non-guaranteed layout, so the collision might not
be with its sibling, but rather some other [seemingly random] field.
Copy link
Contributor

@sjorsdonkers sjorsdonkers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm
Could add an assert checking for zero sized fields

@karlseguin
Copy link
Collaborator Author

In _mapZigInstanceToJs I tried to add this:

if (isEmpty(ptr.child) == false) {
    // existing code
} else if (@TypeOf(js_obj_or_template) != v8.Object and @typeInfo(Receiver(ptr.child)) != .@"opaque" and @sizeOf(ptr.child) == 0) {
    // This else if was added
    @compileLog(@typeName(ptr.child));
} else {
    // existing comment
}

But I get a few false positives.I guess we could create a whitelist of types, but that gets pretty messy.

@karlseguin karlseguin merged commit 3f9b256 into main Jun 26, 2025
19 of 21 checks passed
@karlseguin karlseguin deleted the identity_map_collision branch June 26, 2025 02:24
@github-actions github-actions bot locked and limited conversation to collaborators Jun 26, 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