From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124671 invoked by alias); 11 Feb 2016 23:20:10 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 124663 invoked by uid 89); 11 Feb 2016 23:20:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Wiszkowski, wiszkowski, H*f:dW5w, H*i:dW5w X-HELO: mail-vk0-f43.google.com Received: from mail-vk0-f43.google.com (HELO mail-vk0-f43.google.com) (209.85.213.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 11 Feb 2016 23:20:08 +0000 Received: by mail-vk0-f43.google.com with SMTP id e6so48883562vkh.2 for ; Thu, 11 Feb 2016 15:20:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=niNGpdOkCEk+UVIMopO4jUPvqj1p1jt2xP5W6TlfDlU=; b=JmGxEBbxpnZPIZAFq9XJ6hOuR62Iphu45EooPAW+d4DiOjbXxx3ebr4I6GVqxVT45z QbAcAGzgxEv3FU9DKvAwJ8VE6ZcRJFLw9dQaggqzOw6I9ERbo84Mq2kE20n3fissE161 ub4B2GIwwd3hxVjqoKnpE5nEBgBfqzZY03o8gipPOHI3agG0ohIQZMRKoG4Kt7VvLLOr Qf23KiCo5STvEjwO7I3n1IJO/l9CbS1aQsV8NERWLTXzjnOiNBIsTrsz2cUonb5dThC+ qRWs3sDBz+1TZs+BD/JawS5z3Gpw/Bhaq20DTZfnji7x6s4GOY4ID7zPgaNjKjPC5dkk W0ew== X-Gm-Message-State: AG10YOTS4SuDFh0W+qBuLLFgwsboN2r84FoQI0OYbdsMJ/GDi4LYZxYXc+407eKdDJDUkobHFeuAPO1Ep8IN2Q== MIME-Version: 1.0 X-Received: by 10.31.16.37 with SMTP id g37mr977583vki.97.1455232806197; Thu, 11 Feb 2016 15:20:06 -0800 (PST) Received: by 10.176.67.198 with HTTP; Thu, 11 Feb 2016 15:20:06 -0800 (PST) In-Reply-To: References: Date: Thu, 11 Feb 2016 23:20:00 -0000 Message-ID: Subject: Re: Protobuf string serialization bug with statically linked protobuf 2.5.0 From: Tomasz Wiszkowski To: cygwin@cygwin.com Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-02/txt/msg00167.txt.bz2 A brief correction. I tried to identify further the problem by selectively linking libraries. (-Wl,-Bstatic -lprotobuf.dll -Wl,-Bdynamic) and it turns out the problem emerges the moment i statically link both protobuf _and_ the c++ library. linking everything statically except for libc++ seems to work just fine. i checked if protobuf loads cygc++-6 separately, which would easily explain the problem, but it does not seem to. the problem clearly seems to be interaction between these two. linking libc++ dynamically resolves the problem, but that would also mean shipping the software with artificial add-on... i suspect recompilation still might resolve the issue... -- "My definition of an expert in any field is a person who knows enough about what's really going on to be scared" - P. J. Plauger 2016-02-10 10:54 GMT-08:00 Tomasz Wiszkowski : > Dear all, > > I'm having problems with statically linked executables that use > protocol buffers. > I suspect the problem may be related to incompatibility between > std::string implementation used to compile the library vs. current. If > that's the case, the problem would likely go away with recompilation > of the protocol buffer libraries (protobuf-lite is also exposing the > same problem). > > I have attached a test case as you requested. the example program > compiles two variants - one dynamically linked (works fine) and one > statically linked that crashes upon first attempt to serialize the > protocol buffer. > > It would be great if someone could take a look and possibly rebuild > the static libraries for protocol buffers. > > Best regards, > Tomasz > > -------- example.proto ------------ > syntax = "proto2"; > > package example; > > message ExampleMsg { > optional int32 argc = 1; > optional string argv0 = 2; > }; > > -------- main.cc ------------ > #include > #include > > #include "example.pb.h" > > int main(int argc, char** argv) { > example::ExampleMsg message; > > message.set_argc(argc); > message.set_argv0(argv[0]); > > std::cout << "Serializing protocol buffer." << std::endl; > std::string serialized; > message.SerializeToString(&serialized); // static variant crashes here. > std::cout << "Serialized length: " << serialized.length() << std::endl; > > message.Clear(); > > std::cout << "Deserializing protocol buffer." << std::endl; > message.ParseFromString(serialized); // static variant also crashes here. > std::cout << "Deserialized content: argc=" << message.argc() << ", argv0=" > << message.argv0(); > > return 0; > } > > -------- Makefile ------------ > CFLAGS += -Wall > CXXFLAGS := $(CFLAGS) > CC = g++ > LIBS = -lprotobuf.dll > > all: clean example example-bug > > example.pb.cc: example.proto > protoc --cpp_out=. $^ > > clean: > rm -f *.o *.pb.* *.exe* > > example: example.pb.o main.o > $(CC) $(CFLAGS) $^ -o $@ $(LIBS) > > example-bug: example.pb.o main.o > $(CC) $(CFLAGS) -static $^ -o $@ $(LIBS) -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple