Minor memory Leak in server session B layer on toolkit clear
When several servers are created after several Init/Clear calls, some memory leak may appear on the second Server setup/use.
Note: no actual impact in case program stops after a unique Clear call
When it occurs, there always are 4 items (See complete backtrace below:
session_core_bs__server_set_fresh_nonce
user_authentication_bs__allocate_authenticated_user
- 2 occurrences in
message_in_bs__read_activate_req_msg_locales
The first item can easily be fixed in session_core_bs__INITIALISATION
by forcing to Clear the items initialized in this function (except on first call, of course).
But the 2 other cases are not in static variables of BS module. This may require to implement some close_all_sessions
-like feature.
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x55a4559398b8 in __interceptor_malloc (tests/build/unit_tests+0x18d8b8)
#1 0x55a455a4f02b in SOPC_Malloc libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers_platform_dep/linux/p_sopc_mem_alloc.c:27
#2 0x55a455a7edca in SOPC_CryptoProvider_GenerateRandomBytes libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/crypto/sopc_crypto_provider.c:935
#3 0x55a455a41ac8 in session_core_bs__server_set_fresh_nonce libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/b2c/session_core_bs.c:1710
#4 0x55a455a25338 in session_core__server_internal_activate_req_and_resp libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:77
#5 0x55a455a25ed2 in session_core__server_activate_session_req_and_resp_sm libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:575
#6 0x55a455a27d96 in session_mgr__server_receive_session_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_mgr.c:353
#7 0x55a455a222d3 in service_mgr__server_receive_session_treatment_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/service_mgr.c:776
#8 0x55a455a203d7 in io_dispatch_mgr__receive_msg_buffer libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/io_dispatch_mgr.c:309
#9 0x55a455a01af6 in onSecureChannelEvent libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/sopc_services_api.c:187
#10 0x55a455a53e38 in looper_loop libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers/sopc_event_handler.c:108
#11 0x7fce5a025608 in start_thread /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x55a455939ab6 in __interceptor_calloc (tests/build/unit_tests+0x18dab6)
#1 0x55a455a4f073 in SOPC_Calloc libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers_platform_dep/linux/p_sopc_mem_alloc.c:37
#2 0x55a4559da8e7 in SOPC_UserWithAuthorization_CreateFromIdentityToken libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/configuration/sopc_user_manager.c:177
#3 0x55a455a427bb in user_authentication_bs__allocate_authenticated_user libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/b2c/user_authentication_bs.c:67
#4 0x55a455a2cfb0 in user_authentication__allocate_user_if_authenticated libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/user_authentication.c:54
#5 0x55a455a2d213 in user_authentication__allocate_valid_and_authenticated_user libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/user_authentication.c:168
#6 0x55a455a25e05 in session_core__allocate_authenticated_user libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:541
#7 0x55a455a27d61 in session_mgr__server_receive_session_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_mgr.c:345
#8 0x55a455a222d3 in service_mgr__server_receive_session_treatment_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/service_mgr.c:776
#9 0x55a455a203d7 in io_dispatch_mgr__receive_msg_buffer libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/io_dispatch_mgr.c:309
#10 0x55a455a01af6 in onSecureChannelEvent libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/sopc_services_api.c:187
#11 0x55a455a53e38 in looper_loop libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers/sopc_event_handler.c:108
#12 0x7fce5a025608 in start_thread /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x55a455939ab6 in __interceptor_calloc (tests/build/unit_tests+0x18dab6)
#1 0x55a455a4f073 in SOPC_Calloc libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers_platform_dep/linux/p_sopc_mem_alloc.c:37
#2 0x55a455a5c97a in SOPC_String_GetCStringArray libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/opcua_types/sopc_builtintypes.c:1307
#3 0x55a455a32ac9 in message_in_bs__read_activate_req_msg_locales libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/b2c/message_in_bs.c:294
#4 0x55a455a253b2 in session_core__server_internal_activate_req_and_resp libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:95
#5 0x55a455a25ed2 in session_core__server_activate_session_req_and_resp_sm libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:575
#6 0x55a455a27d96 in session_mgr__server_receive_session_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_mgr.c:353
#7 0x55a455a222d3 in service_mgr__server_receive_session_treatment_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/service_mgr.c:776
#8 0x55a455a203d7 in io_dispatch_mgr__receive_msg_buffer libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/io_dispatch_mgr.c:309
#9 0x55a455a01af6 in onSecureChannelEvent libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/sopc_services_api.c:187
#10 0x55a455a53e38 in looper_loop libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers/sopc_event_handler.c:108
#11 0x7fce5a025608 in start_thread /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477
Indirect leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x55a4559398b8 in __interceptor_malloc (tests/build/unit_tests+0x18d8b8)
#1 0x55a455a4f02b in SOPC_Malloc libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers_platform_dep/linux/p_sopc_mem_alloc.c:27
#2 0x55a455a5c5ff in SOPC_String_GetCString libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/opcua_types/sopc_builtintypes.c:1169
#3 0x55a455a5c9bf in SOPC_String_GetCStringArray libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/opcua_types/sopc_builtintypes.c:1313
#4 0x55a455a32ac9 in message_in_bs__read_activate_req_msg_locales libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/b2c/message_in_bs.c:294
#5 0x55a455a253b2 in session_core__server_internal_activate_req_and_resp libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:95
#6 0x55a455a25ed2 in session_core__server_activate_session_req_and_resp_sm libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_core.c:575
#7 0x55a455a27d96 in session_mgr__server_receive_session_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/session_mgr.c:353
#8 0x55a455a222d3 in service_mgr__server_receive_session_treatment_req libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/service_mgr.c:776
#9 0x55a455a203d7 in io_dispatch_mgr__receive_msg_buffer libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/bgenc/io_dispatch_mgr.c:309
#10 0x55a455a01af6 in onSecureChannelEvent libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/ClientServer/services/sopc_services_api.c:187
#11 0x55a455a53e38 in looper_loop libraries/S2OPC-S2OPC_Toolkit_1.5.0/src/Common/helpers/sopc_event_handler.c:108
#12 0x7fce5a025608 in start_thread /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477
SUMMARY: AddressSanitizer: 70 byte(s) leaked in 4 allocation(s).
Edited by Vincent Monfort