Server crashes due to a subscription over a session with following state transitions: user activated -> orphaned -> closed
Description
The server crashes with following error:
csrc/configuration/sopc_user_manager.c:60: SOPC_UserAuthorization_IsAuthorizedOperation: Assertion `NULL != userWithAuthorization' failed.
Callback:
#10 0x00007f5ca5938bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x5087a5 "NULL != userWithAuthorization", file=file@entry=0x5086a0 "csrc/configuration/sopc_user_manager.c", line=line@entry=60,function=function@entry=0x508a60 <__PRETTY_FUNCTION__.7310> "SOPC_UserAuthorization_IsAuthorizedOperation") at assert.c:92
#11 0x00007f5ca5938c82 in __GI___assert_fail (assertion=0x5087a5 "NULL != userWithAuthorization", file=0x5086a0 "csrc/configuration/sopc_user_manager.c", line=60,
function=0x508a60 <__PRETTY_FUNCTION__.7310> "SOPC_UserAuthorization_IsAuthorizedOperation") at assert.c:101
#12 0x000000000044a4a6 in SOPC_UserAuthorization_IsAuthorizedOperation (userWithAuthorization=0x0, operationType=SOPC_USER_AUTHORIZATION_OPERATION_READ, nodeId=0x7f5c9c001c60, attributeId=6,
pbOperationAuthorized=0x7f5ca2d01dab) at csrc/configuration/sopc_user_manager.c:60
#13 0x00000000004a58ca in user_authorization_bs__get_user_authorization (user_authorization_bs__p_operation_type=constants__e_operation_type_read, user_authorization_bs__p_node_id=0x7f5c9c001c60,
user_authorization_bs__p_attribute_id=constants__e_aid_Value, user_authorization_bs__p_user=0x0, user_authorization_bs__p_authorized=0x7f5ca2d01dab)
at csrc/services/b2c/user_authorization_bs.c:48
#14 0x00000000004b5d98 in subscription_mgr__create_notification_on_monitored_items_if_data_changed (subscription_mgr__p_monitoredItemQueue=0x7f5c9c0016a0, subscription_mgr__p_old_wv_pointer=0x7f5c9c004980,
subscription_mgr__p_new_wv_pointer=0x7f5c9c004b60) at csrc/services/bgenc/subscription_mgr.c:319
#15 0x00000000004b67b0 in subscription_mgr__server_subscription_data_changed (subscription_mgr__p_old_write_value_pointer=0x7f5c9c004980, subscription_mgr__p_new_write_value_pointer=0x7f5c9c004b60)
at csrc/services/bgenc/subscription_mgr.c:804
#16 0x00000000004a19ff in io_dispatch_mgr__internal_server_data_changed (io_dispatch_mgr__p_old_write_value_pointer=0x7f5c9c004980, io_dispatch_mgr__p_new_write_value_pointer=0x7f5c9c004b60,
io_dispatch_mgr__bres=0x7f5ca2d01ebb) at csrc/services/bgenc/io_dispatch_mgr.c:853
#17 0x00000000004913aa in onServiceEvent (handler=0x11f2ac0, scEvent=1540, id=0, params=0x7f5c9c004980, auxParam=140035730983776) at csrc/services/sopc_services_api.c:238
Analysis
The function SOPC_UserAuthorization_IsAuthorizedOperation
is called with an NULL user whereas it is never expected. The callback context is a data change event which triggers notification generation by a subscription.
The context of erroneous case is the following:
- Subscription is created on a session and monitored items are created
- Session becomes orphaned: subscription is notified and publish request are cleared
- Session becomes closed (timeout): subscription is NOT notified (it should be and behavior is already defined to close the subscription in this case)
- Data change occurs on monitored items and subscription attempts to check user rights
Since session was closed the session context was cleared whereas the subscription is not notified:
- Subscription is not closed whereas it shall be
- Subscription uses session cleared context whereas it shall not
Fixes
- Notify the subscription when a session is closed, even if it was already inactivated before, since we have to close the subscription in this case
- Check if a guard is necessary in the model to guarantee session context is valid
Edited by Vincent Monfort