delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/02/10/13:54:43

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=Bb
Rxt5UiTfDVelmuqNjngl6j4U2pcxvG8gTx2ppRUTj6ii/ECSslWnZj2cSvcvxoeA
Swn+hidkYMWo65OLlSjccQ0Vmba1D0qVnN/fcJg+Hx0/WVVhCl2aciQnDm6z/KBz
t6R1Z0n4pEhjETgXrh7F20pfRJl5TN4o9HTrPWGOg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=PMKPFuEh
MvEs31LZG0ErGY51EZQ=; b=KCAhtSdJKk9MHR1VkCkmehBCJIV4mxXm6R1gJa0G
aaVeoDSENfOIVPEDWv/OZVP1nRYlkavyMboimqisz4ixucaUsQmcAjijmL/IbRLl
qixkqoij2Ed6pbohF1O3Mofwlp7e8TCNycOpOvHgvrtqjNlFGX/2UssMC3aeM6fF
J5o=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2022, dear
X-HELO: mail-vk0-f49.google.com
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=oHipsWK/6+t45Vc1fZdwWCK+XAfKJMqTyULJdVdIOTs=; b=Or+TNEsbhiyJh4qTBLfJAn4gCZJvRurilelsc1ybt9LyfdPyFIDyQThvkMJwVZMFUF Zgv+vqOPXtCdmdkiLwXP6Vr8uYtWT5AozI/+WZdEBkG43EMTnMJ061vtztoEcVuUIFAC GslLFNHUxZGQxuPtfS3iP7Udsm+jk6XjrAI3gjlytY+efiup6ZqMjn4I3tRo0OfUsPoo 3Z6W6LzA9Ej4zXd5u5jVnbiK+XvMW5r4iK+vscMum7oUmyG5kmKNr15TYovd5ij97vf8 7vjd+EJ0bH4KTFDBmzxziSJoZy499SVo18xUPQMfypz4Ami3ItOxvbWx2JKucMtxjvOi s5Fg==
X-Gm-Message-State: AG10YOQ5OhG72y3puQ7tHQvqeTAJ8cmVCbAWGcwaeIA3+5TO62fmo8WlH4VOEWO2AvscDvqofBg4MVRFYB9ODQ==
MIME-Version: 1.0
X-Received: by 10.31.8.133 with SMTP id 127mr31061673vki.140.1455130459498; Wed, 10 Feb 2016 10:54:19 -0800 (PST)
In-Reply-To: <CAPqrHhp4haccefOLiD56cR-e5OXOrfpeNH7V__km7CPpN2sdOA@mail.gmail.com>
References: <CAPqrHhp4haccefOLiD56cR-e5OXOrfpeNH7V__km7CPpN2sdOA AT mail DOT gmail DOT com>
Date: Wed, 10 Feb 2016 10:54:19 -0800
Message-ID: <CAPqrHhodtegz8sDm4jzX=2dko3AcT8wWbw+dW5w+XAH4Js-M1g@mail.gmail.com>
Subject: Fwd: Protobuf string serialization bug with statically linked protobuf 2.5.0
From: Tomasz Wiszkowski <tomasz DOT wiszkowski AT gmail DOT com>
To: cygwin AT cygwin DOT com

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 <iostream>
#include <string>

#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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019