Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2124

Memory leak in sub-array schema structure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.2
    • None
    • c
    • None
    • Linux

    Description

      Hi,
      I am seeing some memory leak when using sub-array schema. Please find the snippet of the schema and code below. I have also listed the leak traces. I am doing avro_value_decref() for the root record. Can you please let me know is there any issue in the below coding? Do we need to free() sub-array separately? I tried to reset the db_record using avro_value_reset(), but no luck.

      Also, I tried to free member_list using avro_value_decref(), but that also not fixed this leak issue. Please guide me if there are anything to be changed in the below logic?

      {
      "name": "DBItems",
      "type": "record",
      "fields": [

      { "name": "db_name", "type" : "string" }

      ,

      { "name": "time", "type" : "long" }

      ,
      { "name": "memberList",
      "type": {
      "type": "array",
      "items": {
      "name": "memberRecord",
      "type": "record",
      "fields": [

      { "name" : "db_record_1", "type" : "string" }

      ,

      { "name" : "db_record_2", "type" : "long" }

      ,

      { "name" : "db_record_3", "type" : "long" }

      ,
      ..
      ..
      ]
      }
      }
      ]

      int find_from_schema_add_str(avro_value_t *record, char *name, char *value) {
      avro_value_t field;
      int rval;

      bzero(&field, sizeof (avro_value_t));
      rval = avro_value_get_by_name(record, name, &field, NULL);
      if (rval)

      { return (-1); }
      rval = avro_value_set_string(&field, value);
      if (rval) { return (-1); }

      return
      }

      int find_from_schema_add_long(avro_value_t *record, char *name, long value) {
      avro_value_t field;
      int rval;

      bzero(&field, sizeof (avro_value_t));
      rval = avro_value_get_by_name(record, name, &field, NULL);
      if (rval)

      { return (-1); }
      rval = avro_value_set_long(&field, value);
      if (rval) { return (-1); }

      }

      avro_value_t db_record;
      ..
      ..
      avro_generic_value_new(iface, &db_record);

      find_from_schema_add_str(&db_record, "db_name", cal_get_wwn());
      find_from_schema_add_long(&db_record, "time", genTime);

      rc = avro_value_get_by_name(&db_record, "memberList", &member_list, NULL);
      for (index = 0; index < num; index++)

      { avro_value_t trecord; avro_value_append(&member_list, &trecord, &new_index); find_from_schema_add_str(&trecord, "db_record_1", name); find_from_schema_add_long(&trecord, "db_record_2", val); find_from_schema_add_long(&trecord, "db_record_3", val); .. .. }

      avro_value_decref(&db_record);

      Memory leak
      ===========

      Decoded Symbols:
      /fabos/lib/libmp.so.1.0(snap_realloc+0x164)[0xffc8a6c]
      /fabos/lib/libmp.so.1.0(realloc+0xbc)[0xffc6ba0]
      /usr/lib/libavro.so.23.0.0[0xddeea90]
      /usr/lib/libavro.so.23.0.0(avro_raw_array_ensure_size+0xf0)[0xddef118]
      /usr/lib/libavro.so.23.0.0(avro_raw_array_append+0x44)[0xddef2b0]

      ..
      ..

      Decoded Symbols:
      /fabos/lib/libmp.so.1.0(snap_malloc+0x9c)[0xffc882c]
      /fabos/lib/libmp.so.1.0(snap_realloc+0x58)[0xffc8960]
      /fabos/lib/libmp.so.1.0(realloc+0xbc)[0xffc6ba0]
      /usr/lib/libavro.so.23.0.0[0xddeea90]
      /usr/lib/libavro.so.23.0.0(avro_generic_value_new+0xac)[0xddffbc8]

      ..
      ..

      Decoded Symbols:
      /fabos/lib/libmp.so.1.0(snap_malloc+0x9c)[0xffc882c]
      /fabos/lib/libmp.so.1.0(snap_realloc+0x58)[0xffc8960]
      /fabos/lib/libmp.so.1.0(realloc+0xbc)[0xffc6ba0]
      /usr/lib/libavro.so.23.0.0[0xddeea90]
      /usr/lib/libavro.so.23.0.0[0xde28d10]
      /usr/lib/libavro.so.23.0.0[0xde28fc4]
      /usr/lib/libavro.so.23.0.0(avro_raw_string_set+0x54)[0xde29230]

      Attachments

        Activity

          People

            Unassigned Unassigned
            pviolet pviolet
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: