[
https://issues.apache.org/jira/browse/AVRO-1101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13291158#comment-13291158
]
Douglas Creager commented on AVRO-1101:
---------------------------------------
It's not well-documented, but I think the intention with those accessor
functions is that you borrow the reference from the parent schema. That way if
you loop through the fields in a record schema, you don't have to call
avro_schema_decref on each field. You've got a valid reference to the record,
and the record has references to its fields, so you know the fields will be
valid for however long you're working with the record.
If you want to save a reference to the field somewhere else, though, then it's
your responsibility to call avro_schema_incref on the field before you stash it
away.
I think this reference counting schema was modeled after the Jansson library;
there's a good overview of the borrowed reference idea in [their
documentation|http://www.digip.org/jansson/doc/2.3/apiref.html#reference-count].
So based on all of this, I think a better patch is to document that these
accessor functions return a borrowed reference.
> 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