{"id":53,"date":"2011-09-23T14:44:38","date_gmt":"2011-09-23T19:44:38","guid":{"rendered":"http:\/\/www.p14nd4.com\/blog\/?p=53"},"modified":"2011-09-30T00:02:05","modified_gmt":"2011-09-30T05:02:05","slug":"protobuf-solved-invalid-file-descriptor-data-passed-to-encodeddescriptordatabaseadd","status":"publish","type":"post","link":"https:\/\/www.p14nd4.com\/blog\/2011\/09\/23\/protobuf-solved-invalid-file-descriptor-data-passed-to-encodeddescriptordatabaseadd\/","title":{"rendered":"[protobuf] Solved: Invalid file descriptor data passed to EncodedDescriptorDatabase::Add()"},"content":{"rendered":"<p>I&#8217;ll make this brief, but wanted to document my fix to potentially save someone else some aggravation in the future.<\/p>\n<p>I&#8217;ve been working on a c++ project utilizing <a href=\"http:\/\/code.google.com\/p\/protobuf\/\">Google protobuf<\/a>, and at one point ran into an error during application startup (static initialization):<\/p>\n<blockquote><p>libprotobuf ERROR google\/protobuf\/descriptor_database.cc:314] Invalid file descriptor data passed to EncodedDescriptorDatabase::Add().<br \/>\nlibprotobuf FATAL google\/protobuf\/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size): <br \/>\nAbort (core dumped)<\/p><\/blockquote>\n<p><!--more--><\/p>\n<p>I came across two <a href=\"http:\/\/code.google.com\/p\/protobuf\/issues\/detail?id=290\">bug<\/a> <a href=\"http:\/\/code.google.com\/p\/protobuf\/issues\/detail?id=225\">reports<\/a> against protobuf that experienced this same error, but they seemed to be related to charset conversions. (This was briefly a red herring for me, since I <em>had<\/em> run into a charset issue earlier the same day, but didn&#8217;t end up solving my problem.)<\/p>\n<p>Stepping through the code with a debugger alerted me to where in the code the abort signal was being thrown: from a call to ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(&#8230;) with a big hard-coded string inside the pb.cc (protobuf-generated) file. This was my <q>Eureka!<\/q> moment, since I saw the filename of the original .proto file in the hard-coded string, which reminded me that at one point I&#8217;d renamed my .proto file and message name with &#8216;rename&#8217; and &#8216;sed,&#8217; and while the compiler thought everything was ok, apparently that wasn&#8217;t enough for protobuf.<\/p>\n<h3>Solution<\/h3>\n<p>After see that filename and remember the change I&#8217;d made, I just re-ran <span style=\"font-family: monospace\">protoc &ndash;&ndash;cpp-out=.\/ &lt;message.proto&gt;<\/span>, recompiled, and voil&agrave;, I was able to run without error! (Note that <q>&#8211;cpp_out<\/q> should use two standard hyphens; WordPress likes to be too smart for itself and replace characters with <q>fancier<\/q> versions, and I don&#8217;t want to patch core files on my shared system to fix it.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ll make this brief, but wanted to document my fix to potentially save someone else some aggravation in the future. I&#8217;ve been working on a c++ project utilizing Google protobuf, and at one point ran into an error during application startup (static initialization): libprotobuf ERROR google\/protobuf\/descriptor_database.cc:314] Invalid file descriptor data passed to EncodedDescriptorDatabase::Add(). libprotobuf FATAL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[16,17,19],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-technical","tag-debugger","tag-error","tag-solved"],"_links":{"self":[{"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":12,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/posts\/53\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.p14nd4.com\/blog\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}