Skip to content

Fixed the issue where gc was triggered during the attribute search pr… #5242

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

happy-boy-maker
Copy link

This patch fixes #5084
During the property search process, a gc was triggered. During the gc process, ecma_property_hashmap_create (obj_p) was triggered again on the original object, which led to the final problem. In my personal understanding, the properties of the object should not be modified during the gc process. So, problems can be avoided by adding variables to the context to monitor the status of the gc.
JerryScript-DCO-1.0-Signed-off-by: tangbin [email protected]

…ocess and a hashmap was recreated.

JerryScript-DCO-1.0-Signed-off-by: tangbin [email protected]
@zherczeg
Copy link
Member

Could you give a bit more information? What triggers a property change during gc? Is there a better way to avoid it?

@happy-boy-maker
Copy link
Author

Of course, my explanation above is a bit vague. The problem lies in the property search of the object. During the property search process, if the conditions are met, a hash table will be created, which involves the allocation of memory. When the existing memory is insufficient, it will enter the gc to reclaim the idle memory. During this process, the logic of querying attributes is involved again. Under certain conditions, it seems that the previously created hash table was not discovered during the gc process, so it once more enters the logic of hashmap_create, which leads to the execution of hashmap_create once more within the logic of hashmap_create. As for whether there is a better method, I think the current modification has little impact on the existing code, and the act of modifying the properties on the object during the gc process itself should not occur. The following is the result of my local debugging. I hope it can help you understand this scenario.
image

@zherczeg
Copy link
Member

It seems the problem is entering the hashmap creation. GC normally just check all properties, and does not search anything. It looks like it is a weak map specific thing. The problem should be stopped there.

@happy-boy-maker
Copy link
Author

Your reply reminds me that during the gc process, ecma_op_object_unref_weak was called to remove the weak reference relationship, and from here, ecma_find_named_property was called
image

@zherczeg
Copy link
Member

I suspect unref weak is only used by gc, since deleting from weakset is not possible. We need to avoid the allocation there in some way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants