open62541 / open62541

Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
http://open62541.org
Mozilla Public License 2.0
2.59k stars 1.24k forks source link

Crash when adding Nodes with Multithreading enabled #2312

Open Fischer-Thomas opened 5 years ago

Fischer-Thomas commented 5 years ago

Description

Currently when working with the flag for multithreading enabled there is a problem when adding nodes to the server. The UA_NodeMap_releaseNode asserts that entry->refCount > 0 failed and shortly after the application crashes. Please see the attachment for the callstack.

Background Information / Reproduction Steps

  1. Enable UA_ENABLE_MULTITHREADING when building the server
  2. Start the server.
  3. Add a node to the server with the second thread multithreading_nodes_crash

Checklist

Please provide the following information:

Pro commented 5 years ago

Note that Multithreading support is far from being in beta stadium. Probably this issue will not be fixed for a long time, but feel free to create a PR yourself.

You will have many similar issues like this one. The current recommended way for a multithreaded application is that you use your own mutex to make sure you have mutual exclusion on the UA_Server pointer.