Handle value returned from a SOPC_MethodCallFunc_Ptr more gracefully
Description
Under certain circumstances while handling a CallRequest, the toolkit fails with the following message:
/S2OPC/src/ClientServer/services/b2c/call_method_bs.c:124: call_method_bs__read_exec_result: Assertion `NULL != call_method_bs__execResults.variants' failed.
(no logged error)
Analysis
The stack looks as follows:
#4 0x000000000043a14f in call_method_bs__read_exec_result (call_method_bs__index=1, call_method_bs__value=0x7ffff5c33bd0) at /S2OPC/src/ClientServer/services/b2c/call_method_bs.c:124
#5 0x000000000044ae3f in call_method_mgr__copy_exec_result (call_method_mgr__p_res_msg=0x7ffff0002930, call_method_mgr__p_callMethod=1, call_method_mgr__StatusCode=0x7ffff5c33c70)
at /S2OPC/src/ClientServer/services/bgenc/call_method_mgr.c:336
#6 0x000000000044aa04 in call_method_mgr__treat_one_method_call (call_method_mgr__p_session=20, call_method_mgr__p_req_msg=0x7fffec002780, call_method_mgr__p_res_msg=0x7ffff0002930, call_method_mgr__p_callMethod=1, call_method_mgr__p_endpoint_config_idx=1,
call_method_mgr__StatusCode=0x7ffff5c33c70) at /S2OPC/src/ClientServer/services/bgenc/call_method_mgr.c:124
#7 0x000000000044a937 in call_method_mgr__treat_method_call_request (call_method_mgr__p_session=20, call_method_mgr__p_req_msg=0x7fffec002780, call_method_mgr__p_resp_msg=0x7ffff0002930, call_method_mgr__StatusCode_service=0x7ffff5c33d98)
at /S2OPC/src/ClientServer/services/bgenc/call_method_mgr.c:79
#8 0x000000000042fef7 in service_mgr__treat_session_nano_extended_service_req (service_mgr__endpoint_config_idx=1, service_mgr__session=20, service_mgr__req_typ=constants__e_msg_method_call_req, service_mgr__req_handle=1006697, service_mgr__req_ctx=31,
service_mgr__req_header=0x7ffff00019d0, service_mgr__req_msg=0x7fffec002780, service_mgr__resp_msg=0x7ffff0002930, service_mgr__StatusCode_service=0x7ffff5c33d98, service_mgr__async_resp_msg=0x7ffff5c33e3c)
at /S2OPC/src/ClientServer/services/bgenc/service_mgr.c:427
#9 0x000000000042ff56 in service_mgr__treat_session_service_req (service_mgr__endpoint_config_idx=1, service_mgr__session=20, service_mgr__req_typ=constants__e_msg_method_call_req, service_mgr__req_handle=1006697, service_mgr__req_ctx=31,
service_mgr__req_header=0x7ffff00019d0, service_mgr__req_msg=0x7fffec002780, service_mgr__resp_msg=0x7ffff0002930, service_mgr__StatusCode_service=0x7ffff5c33d98, service_mgr__async_resp_msg=0x7ffff5c33e3c)
at /S2OPC/src/ClientServer/services/bgenc/service_mgr.c:452
#10 0x0000000000430809 in service_mgr__server_receive_session_service_req (service_mgr__channel=1, service_mgr__req_typ=constants__e_msg_method_call_req, service_mgr__req_context=31, service_mgr__msg_buffer=0x7ffff0001050, service_mgr__valid_req=0x7ffff5c33e3d,
service_mgr__async_resp=0x7ffff5c33e3c, service_mgr__sc=0x7ffff5c33e34, service_mgr__buffer_out=0x7ffff5c33e40) at /S2OPC/src/ClientServer/services/bgenc/service_mgr.c:858
#11 0x000000000042ea7c in io_dispatch_mgr__receive_msg_buffer (io_dispatch_mgr__channel=1, io_dispatch_mgr__buffer=0x7ffff0001050, io_dispatch_mgr__request_context=31, io_dispatch_mgr__valid_msg=0x7ffff5c33ea3)
at /S2OPC/src/ClientServer/services/bgenc/io_dispatch_mgr.c:318
#12 0x00000000004249dd in onSecureChannelEvent (handler=0x520300, event=773, id=1, params=140737219924048, auxParam=31) at /S2OPC/src/ClientServer/services/sopc_services_api.c:158
#13 0x0000000000452380 in looper_loop (user_data=0x520120) at /S2OPC/src/Common/helpers/sopc_event_handler.c:104
#14 0x00007ffff7e41609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00007ffff7d5d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
The error means that the *outputArgs
was left NULL
by the Method callback.
TODO
Decide whether the toolkit shall protect against a result produced by a function that is not part of the library.
In this case log an error and return the appropriate OPC UA error in a CallResponse instead of stopping the server.
If we should not protect this code (i.e. keep an assert), at least add an error string that tells the user where to start searching (usually having a NULL
at this point is a minor oversight).