[
https://issues.apache.org/jira/browse/AVRO-1101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13396258#comment-13396258
]
Douglas Creager commented on AVRO-1101:
---------------------------------------
I still disagree with this patch, but haven't closed it yet because I want to
hear from some other C contributors.
I think that the current solution is better. If you call a function that
creates a new schema, you have a reference that you have to decrement. If you
call a function that returns a subschema of a schema that already exists, then
you don't get a new reference automatically. That lets you write a loop very
simply:
{code}
avro_schema_t rec_schema = /* from somewhere */;
size_t count = avro_schema_record_size(rec_schema);
size_t i;
for (i = 0; i < count; i++) {
avro_schema_t field_schema =
avro_schema_record_get_by_index(rec_schema, i);
printf("%zu: %s\n", i, avro_schema_type_name(field_schema));
/* don't have to decref field_schema */
}
{code}
That missing decref isn't much in this simple example, but internally there are
a couple of places where we have to iterate through all of the subschemas when
we process a value — avro_value_copy and avro_value_write, for instance. If
you call avro_value_write on millions of values, and your schema has 10-20
fields, that's just saved you 10-20 million (atomic) increments and decrements.
Those can add up.
> avro-c: reference counting error in avro_schema_record_field_get() and friends
> ------------------------------------------------------------------------------
>
> Key: AVRO-1101
> URL: https://issues.apache.org/jira/browse/AVRO-1101
> Project: Avro
> Issue Type: Bug
> Components: c
> Affects Versions: 1.6.3, 1.7.0
> Reporter: Pugachev Maxim
> Priority: Critical
> Attachments: AVRO-1101.patch, example3.c
>
>
> There is a couple of reference counting errors in avro-c which can produce
> crash bugs. Attached example shows this problem.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira