From 2f6de1ed3e1766bc1150d625450283a1201f4f5c Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 5 May 2026 10:10:28 +0200 Subject: [PATCH] fix(core): retain lazy values before materializing --- src/core/ipc.c | 9 ++++++--- src/store/serde.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/ipc.c b/src/core/ipc.c index 75e4e5b6..f2562541 100644 --- a/src/core/ipc.c +++ b/src/core/ipc.c @@ -1141,7 +1141,8 @@ ray_t* ray_ipc_send(int64_t handle, ray_t* msg) { bool owned = false; if (ray_is_lazy(msg)) { - msg = ray_lazy_materialize(msg); + ray_retain(msg); + msg = ray_lazy_materialize(msg); /* consumes the retain */ if (RAY_IS_ERR(msg)) return msg; owned = true; } @@ -1218,7 +1219,8 @@ ray_err_t ray_ipc_send_async(int64_t handle, ray_t* msg) { bool owned = false; if (ray_is_lazy(msg)) { - msg = ray_lazy_materialize(msg); + ray_retain(msg); + msg = ray_lazy_materialize(msg); /* consumes the retain */ if (RAY_IS_ERR(msg)) { ray_err_t code = ray_err_from_obj(msg); ray_error_free(msg); @@ -1241,7 +1243,8 @@ ray_t* ray_ipc_send_verbose(int64_t handle, ray_t* msg) { bool owned = false; if (ray_is_lazy(msg)) { - msg = ray_lazy_materialize(msg); + ray_retain(msg); + msg = ray_lazy_materialize(msg); /* consumes the retain */ if (RAY_IS_ERR(msg)) return msg; owned = true; } diff --git a/src/store/serde.c b/src/store/serde.c index 003d9c0c..73504260 100644 --- a/src/store/serde.c +++ b/src/store/serde.c @@ -950,7 +950,8 @@ ray_t* ray_de(ray_t* bytes) { ray_err_t ray_obj_save(ray_t* obj, const char* path) { bool owned = false; if (ray_is_lazy(obj)) { - obj = ray_lazy_materialize(obj); + ray_retain(obj); + obj = ray_lazy_materialize(obj); /* consumes the retain */ if (RAY_IS_ERR(obj)) { ray_err_t code = ray_err_from_obj(obj); ray_error_free(obj);