COVESA / capicxx-someip-runtime

Common API C++ SOMEIP runtime
Mozilla Public License 2.0
111 stars 81 forks source link

Possible race condition when serializing attribute's value #18

Closed Almeida-Oco closed 2 years ago

Almeida-Oco commented 3 years ago

The getStubFunctor_ returns a reference to the value to be serialized. This reference is protected by the critical section of the mutex. However, by unlocking the mutex before the serialization isn´t there the possibility of the value being changed unintentionally, even if the user locks the mutex first? If the user even goes so far as to delete the object, the serialization would cause UB right?

https://github.com/GENIVI/capicxx-someip-runtime/blob/0ad2bdc1807fc0f078b9f9368a47ff2f3366ed13/include/CommonAPI/SomeIP/StubAdapterHelper.hpp#L856-L863

Why not unlock it after the outputStream << deployable;?