eclipse-zenoh / zenoh-pico

Eclipse zenoh for pico devices
Other
102 stars 65 forks source link

Replying to a query with a closed session should not yield an UB. #476

Closed jean-roland closed 1 week ago

jean-roland commented 3 weeks ago

Describe the feature

As we removed refcounting on queries, we no longer have the issue of cross-referencing rc that prevented us from refcounting the query session pointer.

A session rc is preferable to a pointer, especially if the query is used out of the callback context and more in line with the rest of the codebase.

DenisBiryukov91 commented 3 weeks ago

Is this really a good idea ? Do we really need to hold on session while query is still alive ? I.e. are we supposed to ignore z_close() and wait till all queries are resolved ?

jean-roland commented 3 weeks ago

I mean the session may outlive the z_close only if the user wants to use the query out of the callback context to make a reply.

The reverse is just a UB/segfault if the query is used to send a reply after z_close.

It feels like the former is better than the latter but it's open to discussion.

jean-roland commented 2 weeks ago

After internal discussion, we'll keep the session as a reference, but we should make sure that replying to a closed session do not result in a UB.