napi_check_object_type_tag returns false if upper in napi_type_tag is 0 #43786
Copy link
Copy link
Closed
Labels
node-apiIssues and PRs related to Node-API.Issues and PRs related to Node-API.
Description
Activity
- addednode-apiIssues and PRs related to Node-API.Issues and PRs related to Node-API.
on Jul 12, 2022 Create a type tag with an upper value of 0.
static const napi_type_tag MyTypeTag = { 0x0, 0xa5ed9ce2e4c00c38 };
I guess you meant
0xa5ed9ce2e4c00c38, 0x0since the first one is for a lower value.node/src/js_native_api_types.h
Lines 160 to 163 in 5fad0b9
typedef struct { uint64_t lower; uint64_t upper; } napi_type_tag; @daeyeon Good catch; that's correct. I was transcribing from Rust and my test code used named fields.
Reacted by Daeyeon Jeong- added a commit that references this issue
on Jul 26, 2022 - added a commit that references this issue
on Jul 31, 2022 - added a commit that references this issue
on Oct 10, 2022 - added a commit that references this issue
on Mar 21, 2024
Metadata
Metadata
Assignees
Labels
node-apiIssues and PRs related to Node-API.Issues and PRs related to Node-API.
Version
All version supporting Node-API 8+
Platform
All
Subsystem
Node-API
What steps will reproduce the bug?
Create a type tag with an
uppervalue of0.Tag an object with it:
Check the type tag:
How often does it reproduce? Is there a required condition?
100% of the time
What is the expected behavior?
napi_check_object_type_tagwill setis_my_typetotrue.What do you see instead?
is_my_typeremainsfalse.Additional information
Type tags are stored in a
BigInt. Ifupperis0, then the leading zero gets truncated and the length is1. However, the follow check expects the length to always be2.node/src/js_native_api_v8.cc
Line 2455 in 5fad0b9
This could could be something like: