Skip to content

crach on reading net parameter and proto from memory buffers #14714

@wanggao1990

Description

@wanggao1990
System information (version)
  • OpenCV => 4.0
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2015
Detailed description

I added and registered some layers, and dnn module can excute normally by invoking function
cv::dnn::Net net = cv::dnn::readNetFromCaffe(configPath,modelPath);.

When i invoke
cv::dnn::Net net = cv::dnn::readNetFromCaffe(configBuf,configLen, modelBuf, modelLen); , a crash occurred, such as bellow:
[libprotobuf ERROR C:\build\master_winpack-build-win64-vc14\opencv\3rdparty\protobuf\src\google\protobuf\text_format.cc:288] Error parsing text-format opencv_caffe.NetParameter: 65:12: Message type "opencv_caffe.LayerParameter" has no field named "xxx_param".

After check out the source code, i found a difference between function ReadProtoFromTextFile and ReadProtoFromTextBuffer.

The former function has an macro implementation like

#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
    return google::protobuf::TextFormat::Parser(true).Parse(&input, proto);
#else
    return google::protobuf::TextFormat::Parser().Parse(&input, proto);
#endif

, but the latter only call return google::protobuf::TextFormat::Parser().Parse(&input, proto);.

Is something wrong when protobuf library parse network witch has unknow fields?
Or perhaps it can run by editing return google::protobuf::TextFormat::Parser(true).Parse(&input, proto); and recompiling?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions