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

fix memleaks in luv_cpu_info #526

Merged
merged 1 commit into from
Jan 19, 2021
Merged

fix memleaks in luv_cpu_info #526

merged 1 commit into from
Jan 19, 2021

Conversation

zhaozg
Copy link
Member

@zhaozg zhaozg commented Jan 18, 2021

uv_cpu_info Gets information about the CPUs on the system.
The cpu_infos array will have count elements and needs to be freed with uv_free_cpu_info().
uv_free_cpu_info should be called when get cpu info fail.

I found this bug when enable AddressSenilizer, when handle:close() for uv_cpu_info.

=================================================================
==26121==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 336 byte(s) in 7 object(s) allocated from:
    #0 0x101d4edc2 in __sanitizer_mz_calloc+0x92 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46dc2)
    #1 0x7fff20171eb6 in _malloc_zone_calloc+0x3a (libsystem_malloc.dylib:x86_64+0x1beb6)
    #2 0x7fff203ac180 in _CFRuntimeCreateInstance+0x124 (CoreFoundation:x86_64h+0x4180)
    #3 0x7fff203ab906 in __CFStringCreateImmutableFunnel3+0x84d (CoreFoundation:x86_64h+0x3906)
    #4 0x7fff203ab0a1 in CFStringCreateWithCString+0x48 (CoreFoundation:x86_64h+0x30a1)
    #5 0x101150371 in uv__get_cpu_speed darwin.c:267
    #6 0x10114e8ae in uv_cpu_info darwin.c:338
    #7 0x100e22053 in luv_cpu_info misc.c:227
    #8 0x1010bde14 in lj_BC_FUNCC+0x43 (luvi-Darwin_x86_64:x86_64+0x100944e14)

Direct leak of 224 byte(s) in 7 object(s) allocated from:
    #0 0x101d4edc2 in __sanitizer_mz_calloc+0x92 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46dc2)
    #1 0x7fff20171eb6 in _malloc_zone_calloc+0x3a (libsystem_malloc.dylib:x86_64+0x1beb6)
    #2 0x7fff203ac180 in _CFRuntimeCreateInstanc%

src/misc.c Outdated Show resolved Hide resolved
@zhaozg
Copy link
Member Author

zhaozg commented Jan 18, 2021

Ref: libuv/libuv#3098

`uv_cpu_info` Gets information about the CPUs on the system.
The cpu_infos array will have count elements and needs to be freed with uv_free_cpu_info().
`uv_free_cpu_info` should be called when get cpu info fail.
@zhaozg zhaozg merged commit 429e75b into luvit:master Jan 19, 2021
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.

2 participants