Skip to content

Conversation

@MarsDoge
Copy link
Contributor

@MarsDoge MarsDoge commented Jul 22, 2025

There has a hidden danger in g_hash_table_resize function:

The g_hash_table_resize, it seems to resize the has table, and write the old value to the new hash table. It seems look for the empty items in the new_nodes, and if the new_nodes is not be cleared, it maybe naver found the empty items. So I added a line under the g_new0 function, and I think clearing new_nodes every time may improve the performance.

Added a memset to clear the new_nodes to fix this problem.
REF: intel/unicorn-for-efi#13

There has a hidden danger in g_hash_table_resize function:

The g_hash_table_resize, it seems to resize the has table, and write the
old value to the new hash table. It seems look for the empty items in
the new_nodes, and if the new_nodes is not be cleared, it maybe naver
found the empty items. So I added a line under the g_new0 function, and
I think clearing new_nodes every time may improve the performance.

Added a memset to clear the new_nodes to fix this problem.
REF: intel/unicorn-for-efi#13

Signed-off-by: Chao Li <lichao@loongson.cn>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
@MarsDoge
Copy link
Contributor Author

@wtdcode please review it, thanks !

@wtdcode
Copy link
Member

wtdcode commented Jul 22, 2025

LGTM.

@wtdcode wtdcode merged commit c8bc9eb into unicorn-engine:dev Jul 22, 2025
44 checks passed
@PhilippTakacs
Copy link
Contributor

Sorry to reopen this, but your observation is wrong. g_new0 already returns zero memory, because function is only a wrapper around calloc. See gmem.h:37 gmem.h:68 and gmem.c:125.

K4ddate pushed a commit to K4ddate/unicorn that referenced this pull request Sep 16, 2025
…icorn-engine#2219)

There has a hidden danger in g_hash_table_resize function:

The g_hash_table_resize, it seems to resize the has table, and write the
old value to the new hash table. It seems look for the empty items in
the new_nodes, and if the new_nodes is not be cleared, it maybe naver
found the empty items. So I added a line under the g_new0 function, and
I think clearing new_nodes every time may improve the performance.

Added a memset to clear the new_nodes to fix this problem.
REF: intel/unicorn-for-efi#13

Signed-off-by: Chao Li <lichao@loongson.cn>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants