111 Commits
Author SHA1 Message Date
Julius Pfrommer 830ba0976d fix(client): detach subscription heads before reentrant cleanup
Separate disposal from list removal so bulk cleanup updates the live list head explicitly before invoking callbacks. Cover recursive cleanup across two subscriptions and use the existing synchronized server pause helpers in the notification regression.
2026-10-28 19:42:09 +01:00
Julius Pfrommer 5bde0ea466 Merge origin/1.5 into master
Adapt the 1.5 fixes to master's discovery, alarms and conditions, session, and nodeset-loader architecture. Preserve master behavior and combine PubSub replay protection with authenticated key rollover. Enable allocation-failure regression coverage and retain both branches' relevant tests.
2026-10-28 17:37:05 +01:00
Niels Beier ced38ccbef feat(client): give up reconnecting once the maximum backoff interval fails 2026-10-26 12:06:23 +01:00
Julius Pfrommer 2499647e6c test: fix allocator-enabled example builds and callback test timeouts
Include stdlib.h explicitly in examples using EXIT_SUCCESS or EXIT_FAILURE. Allocator hooks disable the transitive inclusion through config.h in the alarms coverage build.

Use the existing test-client helper for callback lifetime regressions so client and server share the fake clock and the client has the Valgrind-safe timeout.
2026-10-22 14:17:08 +02:00
Julius Pfrommer d90d30a700 test(client): drive callback lifetime regression deterministically 2026-10-21 22:53:23 +02:00
Julius Pfrommer ac3f42dd27 Merge branch '1.4' into 1.5
Adapt the 1.4 fixes to the 1.5 PubSub, Session, discovery and utility APIs. Preserve per-ReaderGroup authentication, add bounded replay history, harden allocation error paths and widen callback lifetime regression coverage.
2026-10-21 22:53:23 +02:00
Julius Pfrommer ee56907d51 fix(client): make subscription callbacks reentrant
Notification, inactivity and deletion callbacks may remove their subscription or clear the client. Mark deleted objects as removed before invoking user callbacks, revalidate retained subscriptions after callbacks and stop processing when they are gone.
2026-10-21 20:23:09 +02:00
Julius Pfrommer 927cf371b7 refactor(server): Remove UA_ENABLE_METHODCALLS option and always build for methods 2026-10-21 11:30:41 +02:00
Daniel Opitz e211536bda test(client): cover subscription callbacks and publish lifecycle 2026-10-17 14:17:38 +02:00
Daniel Opitz 3a962e77e5 fix(server): preserve keep-alive intervals when publishing is disabled 2026-10-16 15:34:42 +02:00
Julius Pfrommer 3d390d26b1 Merge remote-tracking branch 'origin/1.5' into merge_15_master
# Conflicts:
#	CHANGES.md
#	src/server/ua_services_attribute.c
#	src/server/ua_transport_tcp.c
#	tests/server/check_accesscontrol.c
2026-10-08 14:33:33 +02:00
StalderT 15af9a7618 fix(client): don't reset the outstanding Publish counter in cleanupSession
When a PublishResponse comes back with BadSessionClosed or BadSessionIdInvalid, processMSGResponse takes the request off the list and cleans up the Session before calling the response callback. cleanupSession cancels the other PublishRequests, whose callbacks decrement the counter, and then resets it to zero. The callback of the response that triggered the cleanup runs afterwards and decrements it once more, so the UInt16 wraps to 65535. From then on backgroundPublish never sends a PublishRequest, also not for the next Session, until the client disconnects.

Every PublishRequest already decrements the counter exactly once, when its callback runs for the response or for the cancellation, so the reset is not needed. Remove it.
2026-10-06 12:48:20 +02:00
StalderT 783b0bd287 fix(client): look up the Subscription again after synchronous MonitoredItem calls
The synchronous CreateMonitoredItems and ModifyMonitoredItems keep the Subscription and MonitoredItem pointers across the service call. If the Session is closed meanwhile (BadSessionClosed on a queued Publish, or BadSessionIdInvalid on the request itself), the client removes its Subscriptions before the call returns and these pointers are used after free. For CreateMonitoredItems the MonitoredItem is freed twice and its delete callback runs twice. Look them up again by id and client handle after the call, as the async handlers already do.
2026-10-05 23:36:06 +02:00
Julius Pfrommer 6901aedc07 Merge remote-tracking branch 'origin/1.5' into merge_15_master
Port keyless certificate validation into the GDS receiver driver instead
of restoring the removed server implementation. Preserve master's timer
batching, PubSub lifecycle and client HTTP configuration handling.

Adapt Publish cancellation to response tokens and the HEL/fuzz harnesses
to the explicit TCP driver. Keep SKS policy history and custom datatype
ownership intact, including failed replacement configuration cleanup.
Retain TPM error cleanup while enforcing key-handle and nonce lengths.

Validation:
- Full mbedTLS unit-test build with full namespace, GDS, SKS and Query.
- 21 affected suites passed with ASan/UBSan, plus 9 isolated SKS ownership
  and lifecycle checks.
- OpenSSL certificate update, GDS information model and client encryption
  suites passed with sanitizers.
- OPN, MSG and binary-message fuzzers each completed 100 sanitizer runs.
- Both TPM PubSub policy sources passed compilation checks.

The full SKS client suite timed out after multicast UDP sends reported
"No route to host" on this machine; its affected ownership and lifecycle
cases passed separately. No live TPM hardware validation was performed.
2026-10-04 16:49:17 +02:00
Julius Pfrommer 2a70e31f17 Merge remote-tracking branch 'origin/1.4' into merge_14_15
Adapt the incoming fixes and regressions to the 1.5 encoding options,
nodestore, connection-manager, PubSub and session APIs. Preserve the
strict HEL EndpointUrl limit of less than 4096 bytes.

Cover cancellation of interleaved queued Publish requests, including
response handles, cancellation counts and a successful CancelResponse.
Extend the nodestore mask regression to 1.5's derived attributes and
invalid attribute identifiers.

Validation: full OpenSSL test build; 252 checks passed across the builtin
types, server, attribute services, client subscriptions and mbedTLS PubSub
decryption suites, with sanitizers enabled.
2026-10-04 15:02:49 +02:00
Julius Pfrommer 335cead676 test(mt): synchronize remaining threaded fixture state
Use pointer-sized atomic run flags in threaded fixtures, including dynamically
allocated discovery and browse flags. Pointer sizing supports the MSVC atomic
implementation as well as C11 and GCC atomics.

Serialize the client error-injection test with the server network callbacks
before accessing the internal session and shared send buffer.
2026-09-21 16:23:09 +02:00
Julius Pfrommer 9a43b33a4b Merge remote-tracking branch 'origin/1.5' into merge_15_master
# Conflicts:
#	plugins/crypto/mbedtls/create_certificate.c
#	plugins/crypto/mbedtls/securitypolicy_aes256sha256rsapss.c
#	plugins/crypto/mbedtls/securitypolicy_common.c
#	src/client/ua_client.c
#	src/pubsub/ua_pubsub_config.c
#	src/pubsub/ua_pubsub_keystorage.c
#	src/pubsub/ua_pubsub_keystorage.h
#	src/pubsub/ua_pubsub_ns0.c
#	src/pubsub/ua_pubsub_ns0_sks.c
#	src/pubsub/ua_pubsub_securitygroup.c
#	src/pubsub/ua_pubsub_writer.c
#	src/pubsub/ua_pubsub_writergroup.c
#	src/server/ua_server_ns0.c
#	src/server/ua_server_ns0_gds.c
#	src/server/ua_server_utils.c
#	src/server/ua_services_session.c
#	src/server/ua_subscription_alarms_conditions.c
#	src/ua_types_encoding_xml.c
#	tests/check_types_builtin_xml.c
#	tests/encryption/check_cert_generation.c
#	tests/pubsub/check_pubsub_configuration.c
#	tests/pubsub/check_pubsub_informationmodel_methods.c
#	tests/pubsub/check_pubsub_publish.c
#	tests/pubsub/check_pubsub_sks_client.c
#	tests/pubsub/check_pubsub_sks_keystorage.c
#	tests/pubsub/check_pubsub_sks_push.c
#	tests/pubsub/check_pubsub_sks_securitygroups.c
#	tests/server/check_server_alarmsconditions.c
2026-09-20 10:02:09 +02:00
Julius Pfrommer c15f297b8d Merge remote-tracking branch 'origin/1.4' into merge_14_15
# Conflicts:
#	CHANGELOG
#	CMakeLists.txt
#	plugins/crypto/openssl/securitypolicy_openssl_common.c
#	plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c
#	plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c
#	src/pubsub/ua_pubsub_networkmessage.c
#	src/pubsub/ua_pubsub_ns0.c
#	src/pubsub/ua_pubsub_writer.c
#	src/pubsub/ua_pubsub_writergroup.c
#	src/server/ua_services_monitoreditem.c
#	src/server/ua_services_session.c
#	src/server/ua_session.h
#	tests/CMakeLists.txt
#	tests/check_securechannel.c
#	tests/pubsub/check_pubsub_encryption.c
#	tests/pubsub/check_pubsub_publish.c
#	tests/server/check_server_alarmsconditions.c
2026-09-17 21:58:21 +02:00
Julius Pfrommer acd51270f2 fix(server): validate GetMonitoredItems arguments 2026-09-14 18:07:37 +02:00
Julius Pfrommer a476806541 Merge remote-tracking branch 'origin/1.5' into merge_15_master
# Conflicts:
#	.github/workflows/build_linux.yml
#	CHANGES.md
#	arch/common/eventloop_mqtt.c
#	examples/encryption/server_encryption_filestore.c
#	plugins/crypto/ua_certificategroup_filestore.c
#	src/pubsub/ua_pubsub_networkmessage_json.c
#	src/server/ua_discovery.h
#	src/server/ua_discovery_mdns.c
#	src/server/ua_discovery_mdns_avahi.c
#	src/server/ua_services_attribute.c
#	src/server/ua_services_discovery.c
#	src/server/ua_services_monitoreditem.c
#	src/server/ua_services_nodemanagement.c
#	src/server/ua_subscription.c
#	src/server/ua_subscription.h
#	src/server/ua_subscription_alarms_conditions.c
#	src/server/ua_subscription_event.c
#	src/ua_types_encoding_json_105.c
#	tests/client/check_activateSessionAsync.c
#	tests/server/check_local_monitored_item.c
#	tests/server/check_services_subscriptions.c
2026-09-03 14:33:21 +02:00
StalderT 36b6f1e2e2 test(client): make the notification wait loop actually wait
iterateUntilNotification polls the client with a zero timeout, so its
maxIterations budget is not a duration: the loop spins as fast as the CPU
allows and can return long before a PublishResponse becomes readable on
the socket. Whether the test passes therefore depends on the ratio between
the machine's loopback delivery latency and the cost of one spin. That
ratio is not controlled by the test, which is why the loop can be green on
one host and red on another.

On a WSL2 host the 100 spins take about 0.08ms while the response needs
about 0.6-1.0ms to be delivered, so Client_subscription_modifyMonitoredItem
fails on the initial-value assertion (notificationReceived == 0) on every
run, on unmodified 1.5 and with the CI build options.

Advancing the simulated clock does not help: UA_fakeSleep drives the OPC UA
timers, not the kernel. Measured on the failing host, +2000ms of simulated
time still fails, while giving the same loop real time succeeds after
0.6-1.0ms.

Use a 1ms client timeout so each iteration actually waits, which is what
Client_subscription_createDataChanges in the same file already does. The
assertions are unchanged.
2026-09-02 08:44:08 +02:00
StalderT 398afc538c perf(client): skip the notification re-key scan when none is pending
findMonitoredItemForNotification falls back to a full linear scan of the
MonitoredItem ziptree when a notification clientHandle is not found, to
promote a pending re-key from a ModifyMonitoredItems. A malicious or buggy
server can send a PublishResponse full of notifications with unknown
clientHandles: each triggers the full O(n) scan, i.e. O(N*n) CPU burn on
the single client event-loop thread, stalling reconnection and every other
subscription.

Track the number of pending re-keys per subscription (pendingRekeys) and
skip the scan when it is zero, which is the common case since a re-key is
pending only briefly after a ModifyMonitoredItems. The counter is
maintained where pendingParameters is set (modify), cleared (rollback,
delete) and promoted (on the authoritative notification).

Extend Client_subscription_modifyMonitoredItem_doubleBuffer to assert the
counter (0 -> 1 -> 0) and that a notification with an unknown handle is
dropped without a scan while nothing is pending.
2026-09-01 15:45:08 +02:00
Julius Pfrommer 236f79b489 feat(eventloop): implement Win32 IOCP backend 2026-08-10 19:31:57 +02:00
Julius Pfrommer 15ce1efb4f feat(client): Implement back-pressure for the client when too many async requests are outstanding 2026-07-29 18:14:23 +02:00
Julius Pfrommer 446be6db3b fix(client): double-buffer monitored-item modifications 2026-07-25 22:14:45 +02:00
Andreas Ebner e92e2ea71e test: extend coverage across core, server, client, security and subscription
Add unit tests for previously-uncovered branches and fix registration issues found in PR #8088 review.
2026-07-15 14:15:49 +02:00
Julius Pfrommer 10f9c4ce50 refactor(tests): Fix flakiness of check_client_subscriptions.c 2026-07-02 15:33:07 +02:00
Julius Pfrommer 4b317d1bc6 Merge remote-tracking branch 'origin/1.4' into merge_14_15_2 2026-06-27 20:02:25 +02:00
Julius Pfrommer dc52683a30 refactor(tests): Speed up check_client_subscriptions.c 2026-06-27 10:40:33 +02:00
Julius Pfrommer bbd04f6f37 fix(client): Check for NULL callback pointer in UA_Client_Subscriptions_delete_async (fix #8103) 2026-06-16 16:20:26 +02:00
Julius Pfrommer d2ba952a82 fix(tests): Add some small delays for the lwip CI runs 2026-05-01 16:58:40 +02:00
Andreas Ebner bb2b7ef7b7 tests(client): add coverage tests for client sources 2026-03-11 00:23:47 +01:00
Julius Pfrommer 424e400755 refactor(tests): Remove reliance of client tests on realSleep 2025-11-05 09:03:43 +01:00
Florian La Roche 86a072851b refactor(examples,tools,server,plugins): clang compiler warnings
Fix some clang compiler warnings about:
- not-needed semicolons
- unused macros
- sign conversion in ua-cli

Signed-off-by: Florian La Roche <f.laroche@pilz.de>
2025-07-25 17:14:53 +02:00
Julius Pfrommer be62f5700a refactor(client): Also timeout subscriptions when the Session is not activated 2025-06-04 15:32:47 +02:00
Julius Pfrommer de6e63bfff refactor(client): Pull in inline definitions and better typing of async callback methods 2025-02-20 10:45:26 +01:00
Julius Pfrommer 5bba2ba794 refactor(core): Fold the <type>_generated_handling.h into <type>_generated.h 2024-05-29 06:14:56 +02:00
Julius Pfrommer 09317bcc00 Merge remote-tracking branch 'origin/1.4' 2023-11-14 17:39:04 +01:00
Julius Pfrommer 9f3adac3d1 feat(test): Add test for MonitoredItem with negative sampling interval 2023-11-08 23:14:09 +01:00
Julius Pfrommer 9eee407857 Merge remote-tracking branch 'origin/1.4' into merge_14_master_7 2023-10-22 11:32:38 +02:00
Julius Pfrommer 71fe28c869 fix(test): Make check_client_subscriptions.c time-deterministic 2023-10-22 10:51:09 +02:00
Julius Pfrommer dd300f3eff refactor(tests): Set a custom "fake" clock in the EventLoop for unit tests 2023-10-04 10:56:26 +02:00
Julius Pfrommer 928931ec36 refactor(core): Move architecture-specific definition out of the public headers 2023-07-28 21:42:56 +02:00
Julius Pfrommer 52c8b0c4f4 Merge remote-tracking branch 'origin/1.3' into merge_master_13_11 2023-05-09 15:17:55 +02:00
Jiří Engelthaler 80c3e91675 fix(server): Transfer subscription - fix queued subscription notifications
When transferring a subscription, TAILQ_FOREACH_SAFE must be used for
queued subscription notifications.

Unit test updated.

Fix #5774
2023-05-09 15:14:49 +02:00
Julius Pfrommer b19cc6d78c refactor(core): Remove UA_SECURECHANNELSTATE_FRESH
Instead use UA_SECURECHANNELSTATE_CLOSED as the default.
This is the pattern used everywhere else as well.
2023-04-29 22:25:30 +02:00
Julius Pfrommer 4d5ceb378c Merge remote-tracking branch 'origin/1.3' into merge_13_master_12 2023-03-26 10:21:49 +02:00
Julius Pfrommer 67a4cb637d fix(client): Fix crash during Client_delete (#5649)
UA_Client_AsyncService_removeAll was called "reentrant" leading to an
unauthorized memory access.
2023-02-19 21:15:10 +01:00
Julius Pfrommer 282b5a582b fix(tests): Make check_client_subscriptions more robust wrt timings 2023-02-14 00:40:31 +01:00
Andreas Eckerstorfer 022ad60723 fix (tests): Check server instance in UNIT tests
Failed UNIT tests caused an exception in the server loop, if the
server instance could not be created.
2023-01-31 00:07:18 +01:00