Hello.
I try to use NvCaffeParser and Protobuf in a project, but it fails at runtime with a cryptic message:
../../../externals/protobuf/aarch64/10.0/include/google/protobuf/generated_message_util.h:84:
const string& google::protobuf::internal::GetEmptyStringAlreadyInited():
Assertion `empty_string_ != __null' failed.
I made a minimal reproducible example. The main file is just:
#include <iostream>
#include "NvCaffeParser.h"
// Not even needed to make it bug
// #include "bug.pb.h"
int main() {
nvcaffeparser1::ICaffeParser* parser = nvcaffeparser1::createCaffeParser();
std::cout << "OK" << std::endl;
return 0;
};
The CMakeLists looks like this:
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "-std=c++11")
find_package(Protobuf REQUIRED)
# Commenting the following line removes the bug
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS bug.proto)
include_directories(${CMAKE_BINARY_DIR})
add_executable(protobug main.cc ${PROTO_SRCS})
target_link_libraries(protobug ${PROTOBUF_LIBRARIES} nvcaffe_parser)
I shared all the files in a public repository, so testing it is a simple as this:
git clone https://AdrienBilberry@bitbucket.org/AdrienBilberry/nvcaffeparser-protobuf-bug.git && \
cd nvcaffeparser-protobuf-bug && \
./test_bug.sh
It is tested on a freshly flashed Jetson TX1 with JetPack 3.0 (bug appears in 2.3 too). Once flashed, I simply built and installed Protobuf from source (see install_protobuf.sh in the repo). I had to use the v3.0.0 otherwise I would get an error stating that aarch64/ditcaffe.pb.cc compiled version (3.0.0) was incompatible with installed version (3.2.0).
I am stuck on this since several weeks now. Any help would be much appreciated. Do you think it is an inner bug of NvCaffe? I guess it uses Protobuf internally, could this causes conflicts?