-
Notifications
You must be signed in to change notification settings - Fork 79
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
Allow symbols as WeakMap and WeakSet keys #58
Conversation
|
Ah nice! I think you accidentally added support for putting them in a weakest too! |
The PR LGTM as is. A thought: looking at implementing WeakRef and FinalizationRegistry we'd likely need to move away from the current model to accomodate that I think. |
Yes, I think so too. What I don't like about this PR is that it makes JSString bigger by an otherwise unused pointer. Branching on the tag to get the field offset is kind of yuck too although that could be fixed by unifying the JSObject and JSString header, but that puts a mostly unused field in precious small offset-from-base territory. |
3f068c7
to
db83469
Compare
db83469
to
f2f0536
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
I don't think the asan bot is wrong to complain. I'll investigate more tomorrow. |
Diagnosis: JS_FreeRuntime calls free_object, which then calls JS_FreeAtomStruct before js_map_finalizer, resulting in a UAF when js_map_finalizer calls delete_weak_ref. Atoms probably need to add themselves to |
That does sound like it would fix the dump free issue too maybe? |
f2f0536
to
9057c66
Compare
Nah, turns out the bug was mine, I missed a delete_weak_ref call somewhere. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff!
This is not a proper fix but it shows why #56 crashes.
map_add_record() treat the key as a JSObject when it can be a JSAtomStruct/JSString. As a quick hack I added the necessary
struct JSMapRecord
to JSString.I'll think about this some more tomorrow, it's late now. :-)