nanomq / NanoNNG

The NNG submodule of NanoMQ
MIT License
47 stars 20 forks source link

HTTP API get_clients cause memleak of conn_param #471

Open JaylinYu opened 1 year ago

JaylinYu commented 1 year ago

==867197==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 512 byte(s) in 2 object(s) allocated from:

0 0x7f8792eb4867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145

#1 0x557d46b43323 in nni_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_alloc.c:20
#2 0x557d46b11cf9 in nng_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/nng.c:60
#3 0x557d46b66d80 in conn_param_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:853
#4 0x557d46ea1bad in tcptran_pipe_nego_cb /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:360
#5 0x557d46b3d74e in nni_taskq_thread /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/taskq.c:50
#6 0x557d46b3eb06 in nni_thr_wrap /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/thread.c:94
#7 0x557d46b47cbb in nni_plat_thr_main /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_thread.c:266
#8 0x7f8792694b42 in start_thread nptl/pthread_create.c:442

Indirect leak of 10 byte(s) in 2 object(s) allocated from:

0 0x7f8792eb4867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145

#1 0x557d46b43323 in nni_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_alloc.c:20
#2 0x557d46b11cf9 in nng_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/nng.c:60
#3 0x557d46b62383 in copyn_utf8_str /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:238
#4 0x557d46b642a3 in conn_handler /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:597
#5 0x557d46ea1c5f in tcptran_pipe_nego_cb /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:363
#6 0x557d46b3d74e in nni_taskq_thread /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/taskq.c:50
#7 0x557d46b3eb06 in nni_thr_wrap /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/thread.c:94
#8 0x557d46b47cbb in nni_plat_thr_main /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_thread.c:266
#9 0x7f8792694b42 in start_thread nptl/pthread_create.c:442

Indirect leak of 10 byte(s) in 2 object(s) allocated from:

0 0x7f8792eb4867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145

#1 0x557d46b43323 in nni_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_alloc.c:20
#2 0x557d46b11cf9 in nng_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/nng.c:60
#3 0x557d46b62383 in copyn_utf8_str /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:238
#4 0x557d46b64cb6 in conn_handler /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:640
#5 0x557d46ea1c5f in tcptran_pipe_nego_cb /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:363
#6 0x557d46b3d74e in nni_taskq_thread /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/taskq.c:50
#7 0x557d46b3eb06 in nni_thr_wrap /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/thread.c:94
#8 0x557d46b47cbb in nni_plat_thr_main /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_thread.c:266
#9 0x7f8792694b42 in start_thread nptl/pthread_create.c:442

Indirect leak of 8 byte(s) in 2 object(s) allocated from:

0 0x7f8792eb4867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145

#1 0x557d46b43323 in nni_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_alloc.c:20
#2 0x557d46b11cf9 in nng_alloc /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/nng.c:60
#3 0x557d46b62383 in copyn_utf8_str /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:238
#4 0x557d46b65b14 in conn_handler /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/protocol/mqtt/mqtt_parser.c:712
#5 0x557d46ea1c5f in tcptran_pipe_nego_cb /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:363
#6 0x557d46b3d74e in nni_taskq_thread /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/taskq.c:50
#7 0x557d46b3eb06 in nni_thr_wrap /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/core/thread.c:94
#8 0x557d46b47cbb in nni_plat_thr_main /home/jaylin/Projects/EdgeComputing/nanomq/nng/src/platform/posix/posix_thread.c:266
#9 0x7f8792694b42 in start_thread nptl/pthread_create.c:442

SUMMARY: AddressSanitizer: 540 byte(s) leaked in 8 allocation(s).

ashamedbit commented 9 months ago

Is there a testcase or a command to reproduce this? I can try to fix it.