-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed mutex assertion with TCP_sendWithConnection() in 1.4 #6455
Comments
This was referenced May 3, 2024
uklotzde
added a commit
to HMIProject/open62541
that referenced
this issue
May 8, 2024
## Description This PR is a follow-up to #102 and adds an example that triggers the assertion error in open62541/open62541#6455. A typical run looks like this: ``` > cargo run --example async_concurrent Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s Running `target/debug/examples/async_concurrent` Children: 26 Children: 26 Children: 26 Assertion failed: (lock->mutexCounter == num), function UA_LOCK_ASSERT, file config.h, line 422. fish: Job 1, 'cargo run --example async_read_…' terminated by signal SIGABRT (Abort) ``` --------- Co-authored-by: Uwe Klotz <uwe.klotz@gmail.com>
@jpfr I'd like to contribute a PR but I'm unsure whether it's sufficient to just remove the assertion (because it describes an invalid assumption) or to actually take the lock instead. |
sgoll
added a commit
to HMIProject/open62541
that referenced
this issue
May 17, 2024
## Description This PR temporarily adds back a mutex to serialize library calls in `AsyncClient`. The entire commit should be reverted and the mutex removed again when the issue described in open62541/open62541#6455 has been resolved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Background Information / Reproduction Steps
When issuing concurrent calls to both
UA_Client_run_iterate()
and__UA_Client_AsyncService()
, there is a race condition where the following assertion at the beginning ofTCP_sendWithConnection()
may fail:open62541/arch/eventloop_posix_tcp.c
Lines 627 to 629 in 8434782
This manifests itself in the following error at runtime. Both functions are marked
UA_THREADSAFE
:My guess is that this happens when
__UA_Client_AsyncService()
tries to send out the request while another thread holds the mutex lock while iterating the event loop from withinUA_Client_run_iterate()
. Looking at the log output preceding the failed assertion, it seems that at the same time as sending the request, the response to another request arrives at the client:Used CMake options:
Checklist
Please provide the following information:
UA_LOGLEVEL
set as low as necessary) attachedThe text was updated successfully, but these errors were encountered: