PengZheng commented on issue #723:
URL: https://github.com/apache/celix/issues/723#issuecomment-1908374062
I try to give the following definitions:
**Standard argument should be serializable.** All types except types
involving untyped pointer or double pointer (pointer to pointer) are
serializable. For example, complex types consisting of non-pointer fields are
serializable while complex type containing a untyped pointer field is not
serializable; `[I` is serializable while `[P` and `[**D` are not serializable.
`am=out` parameter should be pointer to text or double pointer to
serializable types.
`am=pre` parameter should be pointer to **trivially copyable type**. It's
safe to apply `memcpy` rivially copyable type without the usual danger of
shallow copy. However, this definition is only meant to make the following code
work:
```C
if (meta ==
DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
void *tmp = NULL;
void **out = (void **) args[i];
size_t size = 0;
dynType_typedPointer_getTypedType(argType, &argType);
status = jsonSerializer_deserializeJson(argType,
result, &tmp);
if (tmp != NULL) {
size = dynType_size(argType);
memcpy(*out, tmp, size);
}
dynType_free(argType, tmp);
```
By this definition, `[D` can not be used as `am=pre`, because
`dynType_free(argType, tmp)` will free the embedded buffer, which has been
copied to `*out` (thus lead to use-after-free). I think the main usage of
SequenceType is to be used as pre-allocated output paramter and let the callee
to fill in actual content. Thus this definition will make SequenceType useless.
Any ideas to make `am=pre` work? @pnoltes
--
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]