Broken introspection when structs contain other arrays
The "NAS Get Cell Location Info" response message has a TLV named "Interfrequency LTE Info". This TLV is composed of a boolean and an array of structs. Each of those structs is composed of several uint values and an additional inner array of structs of some other type:
TLV
|->boolean
|->array of structs type#1
|->each struct type#1:
|->uint
|->uint
|->array of structs #type2
|->each struct #type2:
|->uint
|->uint
The generated code in the API is via a GArray
of structs in each case.
The first array of structs of type#1 seems to work well via introspection, e.g. one can access the boolean element just fine. But trying to access the inner array ends up triggering an error like this one:
** (process:369671): CRITICAL **: 11:32:56.427: Stack overflow protection. Can't copy array element into GIArgument.
After reading about this type of problem, it looks like gobject-introspection cannot properly handle GArray
of structs like these. The "correct" way to handle this would have been to have arrays of pointers to structs instead, treating the structs as boxed types that can be freed/copied independently.
I have a working implementation of a fix for this issue by using GPtrArray
in the APIs when treating with arrays of items that require extra allocations (e.g. arrays of strings, arrays of structs, arrays of arrays). But this change BREAKS API badly, as there are a lot of methods expecting GArray
of structs that would now use GPtrArray
of pointers to the structs instead. See !308 (closed)
Still trying to find a better solution to this than this huge API break, but not yet very clear what else could be done.