The below mentioned sample program is working without any issues in single 
threaded application but when the same program ran in multithreaded causing the 
below mentioned Bus error.

The application creates a four threads and each thread will run the below 
mentioned code and serialized the data.


Program terminated with signal 7, Bus error.
#0  0x00007fb74417d656 in avro_write (writer=0x353a353020343220,
    buf=0x7fb6cfffe970, len=5)
    at /Desktop/avro-c-1.7.7/src/io.c:357
357 if (is_memory_io(writer)) {
Missing separate debuginfos, use: debuginfo-install glib2-2.28.8-4.el6.x86_64 
glibc-2.12-1.149.el6.x86_64 libgcc-4.4.7-11.el6.x86_64 
libpcap-1.4.0-1.20130826git2dbcaa1.el6.x86_64 libstdc++-4.4.7-11.el6.x86_64 
snappy-1.1.0-1.el6.x86_64 zlib-1.2.3-29.el6.x86_64

bt
#0  0x00007fb74417d656 in avro_write (writer=0x353a353020343220, buf=
    0x7fb6cfffe970, len=5) at /home/murali/Desktop/avro-c-1.7.7/src/io.c:357
#1  0x00007fb74417a0dd in write_long (writer=<value optimized out>,
    l=<value optimized out>)
    at /home/murali/Desktop/avro-c-1.7.7/src/encoding_binary.c:77
#2  0x00007fb744173b24 in file_write_block (w=0x7fb6c431d450)
    at /home/murali/Desktop/avro-c-1.7.7/src/datafile.c:558
#3  0x00007fb744173e48 in avro_file_writer_append_value (w=0x7fb6c431d450,
    value=0x7fb6cfffea98)
    at /home/murali/Desktop/avro-c-1.7.7/src/datafile.c:612


const char  *SCHEMA =
"{"
"   \"namespace\": \"xyz\","
"   \"type\": \"record\" ,"
"   \"name\": \"Headers\" ,"
"   \"fields\": ["
"   {\"name\": \"headers\","
"   \"type\":{"
"  \"type\": \"array\","
"  \"items\":{"
"  \"type\": \"record\","
"   \"name\": \"RequestHeader\","
"  \"fields\": ["
"   { \"name\": \"attribute\", \"type\": \"string\" },"
"   { \"name\": \"value\", \"type\": \"string\" }"
"  ]"
"  }"
"  }"
"  }"
"  ]"
"}";


avro_file_writer_t  file;
avro_schema_t  writer_schema;
avro_value_iface_t  *writer_iface;
avro_value_t  writer_value;
avro_value_t  field;
avro_schema_error_t  error;
size_t length = 0;

/* Initializing the avro attributes */
check_i(rval,avro_schema_from_json(schema, length, &writer_schema, &error));
av->writer_iface = avro_generic_class_from_schema(writer_schema);

check_i(rval,avro_generic_value_new(av->writer_iface, &av->writer_value));

check_i(rval,avro_file_writer_create_with_codec(filename, av->writer_schema, 
&av->file, QUICKSTOP_CODEC, 5120000));
data *node;


/* serializing the data using avro schema */
check_i(rval,avro_value_get_by_name(&writer_value,"headers", &headers, NULL));

/* adds the array of records to a record (header) */
        while(node)
        {
            avro_value_t attribute,element,value;
            check_i(rval,avro_value_append( &headers, &element, NULL));
            check_i(rval,avro_value_get_by_name(&element,"attribute", 
&attribute, NULL));
            
check_i(rval,avro_value_set_string_len(&attribute,node->header_name,strlen(node->header_name)+1));
            check_i(rval,avro_value_get_by_name(&element,"value", &value, 
NULL));
            
check_i(rval,avro_value_set_string_len(&value,node->header_value,node->header_value_length+1));
            node = node->next;
        }
check_i(rval,avro_file_writer_append_value(file, &writer_value));
    }

/* cleanup the avro attributes */?
 avro_file_writer_flush(file);
 avro_file_writer_close(file);
 avro_value_decref(&writer_value);
 avro_value_iface_decref(writer_iface);
 avro_schema_decref(writer_schema);


could someone please help me to figure what's wrong with the above code that is 
causing the issue.

Thanks
Murali



Reply via email to