Open erdem-kose opened 2 years ago
solved this by changing this function in onnx.c
char * onnx_attribute_read_string(struct onnx_node_t * n, const char * name, char * def)
{
Onnx__AttributeProto * attr = onnx_search_attribute(n, name);
if(attr && (attr->type == ONNX__ATTRIBUTE_PROTO__ATTRIBUTE_TYPE__STRING))
{
if(attr->s.len > 0)
{
attr->s.data=realloc(attr->s.data,attr->s.len+1);
if(attr->s.data==NULL)
return def;
attr->s.data[attr->s.len] = 0;
return (char *)attr->s.data;
}
}
return def;
}
I downloaded tiny yolo v2 model from https://github.com/onnx/models/tree/main/vision/object_detection_segmentation/tiny-yolov2 And when inferencing this, I got those outputs from Valgrind
==178736== Invalid read of size 1 ==178736== at 0x162DF9: shash (onnxconf.h:146) ==178736== by 0x162F11: MaxPool_init (MaxPool.c:38) ==178736== by 0x113FF0: onnx_graph_alloc (onnx.c:1238) ==178736== by 0x10FCFA: onnx_context_alloc (onnx.c:102) ==178736== by 0x10FF35: onnx_context_alloc_from_file (onnx.c:145)
==178736== Invalid write of size 1 ==178736== at 0x1154F1: onnx_attribute_read_string (onnx.c:1747) ==178736== by 0x162F09: MaxPool_init (MaxPool.c:38) ==178736== by 0x113FF0: onnx_graph_alloc (onnx.c:1238) ==178736== by 0x10FCFA: onnx_context_alloc (onnx.c:102) ==178736== by 0x10FF35: onnx_context_alloc_from_file (onnx.c:145)
==178736== Invalid read of size 1 ==178736== at 0x13BEB8: shash (onnxconf.h:146) ==178736== by 0x13BFD1: Conv_init (Conv.c:43) ==178736== by 0x113FF0: onnx_graph_alloc (onnx.c:1238) ==178736== by 0x10FCFA: onnx_context_alloc (onnx.c:102) ==178736== by 0x10FF35: onnx_context_alloc_from_file (onnx.c:145)
==178736== Invalid write of size 1 ==178736== at 0x1154F1: onnx_attribute_read_string (onnx.c:1747) ==178736== by 0x13BFC9: Conv_init (Conv.c:43) ==178736== by 0x113FF0: onnx_graph_alloc (onnx.c:1238) ==178736== by 0x10FCFA: onnx_context_alloc (onnx.c:102) ==178736== by 0x10FF35: onnx_context_alloc_from_file (onnx.c:145)
==178736== ERROR SUMMARY: 30 errors from 4 contexts (suppressed: 0 from 0)