Skip to content

Conversation

@rzr
Copy link
Collaborator

@rzr rzr commented Apr 30, 2025

Now events are forwarded to C++ handler functions by reference, instead of pointers, it is safer to avoid potential use on null pointers.

So now on, previously allocated (in post) user data are freed just after handling them.

I am assuming that once events are posted, the owner is the contiki event loop, which should free events data once consumed by handler.

In other works contiki is managing the lifecyle of user data.

Note that once event is processed, the address still remain in contiki queue but no more referenced since the queue pointer is moving to the next one.

A later change for contiki can explicitly set the consumed pointer to null in consumed queue cell.

Relate-to: UIC-3659
Relate-to: https://github.com/SiliconLabsSoftware/z-wave-engine-application-layer/issues/17

Change

Checklist

rzr added a commit to rzr/UnifySDK that referenced this pull request Apr 30, 2025
This prevent potential access to invalid address,
typically after a deletion.

This change should be forwarded upstream, once contiki dependency is
managed in modular way (using ref to upstream not code dump).

Relate-to: SiliconLabsSoftware/z-wave-protocol-controller#94
Relate-to: UIC-3659
Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#17
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
rzr added a commit to rzr/UnifySDK that referenced this pull request Apr 30, 2025
This prevent potential access to invalid address,
typically after a deletion.

This change should be forwarded upstream, once contiki dependency is
managed in modular way (using ref to upstream not code dump).

Origin: SiliconLabs#52
Relate-to: SiliconLabsSoftware/z-wave-protocol-controller#94
Relate-to: UIC-3659
Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#17
Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#40
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
Now events are forwarded to C++ handler functions by reference, instead of
pointers, it is safer to avoid potential use on null pointers.

So now on, previously allocated (in post) user data are freed just after
handling them.

I am assuming that once events are posted, the owner is the contiki
event loop, which should free events data once consumed by handler.

In other works contiki is managing the lifecyle of user data.

Note that once event if processed, the address still remain in contiki
queue but no more referenced since the queue pointer is moving to the
next one.

A later change for contiki can explicitly set the consumed pointer to
null in consumed queue cell.

Relate-to: UIC-3659
Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#17
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
@rzr rzr force-pushed the zpc/network/review/main branch from 41909f2 to 8db135b Compare April 30, 2025 16:39
@rzr
Copy link
Collaborator Author

rzr commented May 12, 2025

Let's merge it since there is no negative feedback after 2 weeks

@rzr rzr merged commit 2f6e9c9 into main May 12, 2025
1 check passed
@rzr rzr deleted the zpc/network/review/main branch May 20, 2025 15:19
Thomasdjb pushed a commit to Thomasdjb/z-wave-protocol-controller that referenced this pull request Oct 28, 2025
Now events are forwarded to C++ handler functions by reference, instead of
pointers, it is safer to avoid potential use on null pointers.

So now on, previously allocated (in post) user data are freed just after
handling them.

I am assuming that once events are posted, the owner is the contiki
event loop, which should free events data once consumed by handler.

In other works contiki is managing the lifecyle of user data.

Note that once event if processed, the address still remain in contiki
queue but no more referenced since the queue pointer is moving to the
next one.

A later change for contiki can explicitly set the consumed pointer to
null in consumed queue cell.

Relate-to: UIC-3659
Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#17
Origin: SiliconLabsSoftware#94
Forwarded: SiliconLabsSoftware/z-wave-engine-application-layer#41
Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants