jmalkin commented on code in PR #69:
URL:
https://github.com/apache/datasketches-bigquery/pull/69#discussion_r1797479544
##########
theta/sqlx/theta_sketch_agg_int64_lgk_seed_p.sqlx:
##########
@@ -89,18 +81,19 @@ export function serialize(state) {
}
} else if (state.sketch != null) {
state.serialized = state.sketch.serializeAsUint8ArrayCompressed();
+ state.sketch.delete();
+ delete state.sketch;
} else if (state.union != null) {
state.serialized = state.union.getResultAsUint8ArrayCompressed();
+ state.union.delete();
+ delete state.union;
}
- return {
- lg_k: state.lg_k,
- seed: state.seed,
- serialized: state.serialized
- };
+ return state;
} catch (e) {
throw new Error(Module.getExceptionMessage(e));
} finally {
- destroyState(state);
+ if (state.sketch != null) state.sketch.delete();
Review Comment:
I think here (and the next line) we need to explicitly delete `state.sketch`
and `state.union` from the struct. Otherwise multiple deserialize->aggregate
transitions might risk use-after-free errors. Not 100% sure, but I'd certainly
feel better ensuring it can't happen.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]