Skip to content
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

unqlite: fix the memory leak about cell table #164

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

Conversation

CV-Bowen
Copy link
Contributor

@CV-Bowen CV-Bowen commented Jan 4, 2024

Page cell table is alloced in lhInstallCell() when pPage->nCell < 1, but not free the cell table when pPage->nCell == 0.

So when in the next call of lhInstallCell() and pPage->nCell == 0, cell table is mallcoed again and old cell table not freed. Memory leak happends.

Memory Leak Backtrace:

malloc at nuttx/mm/umm_heap/umm_malloc.c:64
SyOSHeapAlloc atexternal/unqlite/unqlite/unqlite.c:26906
 (inlined by) MemOSAlloc at external/unqlite/unqlite/unqlite.c:27095
MemBackendAlloc at external/unqlite/unqlite/unqlite.c:27149
SyMemBackendAlloc at external/unqlite/unqlite/unqlite.c:27179
(discriminator 3) lhInstallCell at external/unqlite/unqlite/unqlite.c:49029
lhStoreCell at external/unqlite/unqlite/unqlite.c:50741
lhRecordInstall at external/unqlite/unqlite/unqlite.c:51065
 (inlined by) lh_record_insert at external/unqlite/unqlite/unqlite.c:51156
lh_record_insert at external/unqlite/unqlite/unqlite.c:51103
 (inlined by) lhash_kv_replace at external/unqlite/unqlite/unqlite.c:51184

Page cell table is alloced in lhInstallCell() when pPage->nCell < 1,
but not free the cell table when pPage->nCell == 0.

So when in the next call of lhInstallCell() and pPage->nCell == 0, cell
table is mallcoed again and old cell table not freed. Memory leak
happends.

Memory Leak Backtrace:
malloc at /data/project/n62/rel-4.0/nuttx/mm/umm_heap/umm_malloc.c:64
SyOSHeapAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:26906
 (inlined by) MemOSAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27095
MemBackendAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27149
SyMemBackendAlloc at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:27179 (discriminator 3)
lhInstallCell at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:49029
lhStoreCell at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:50741
lhRecordInstall at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51065
 (inlined by) lh_record_insert at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51156
lh_record_insert at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51103
 (inlined by) lhash_kv_replace at /data/project/n62/rel-4.0/external/unqlite/unqlite/unqlite.c:51184

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
@CV-Bowen
Copy link
Contributor Author

CV-Bowen commented Jan 4, 2024

@symisc I found a memory leak problem. Could take a look? Thanks.

@CV-Bowen CV-Bowen changed the title unqlite: fix the memmory leak about cell table unqlite: fix the memory leak about cell table Jan 4, 2024
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.

None yet

1 participant