On Sat, Apr 7, 2012 at 21:18, G. <geula.vainap...@mediamind.com> wrote:
> Hi Hans,
>
> In my proto file, there are two structures, Auction and Bid. The
> Auction structure behaves normally - setting the fields works
> correctly. I am also using the pre-defined realtime-bidding.proto
> file, all of which structures are working fine. It is only the Bid
> structure that acts broken, and I can't see why - because there is
> nothing special about its definition.
>
> I am using the protoc.exe compiler that came with the protobuf 2.4.1
> installation package for windows, and my IDE is visual studio 2010
> professional, everything is compiled in x64.

One idea I can think of is that you forgot to allocate the Bid
structure and your compiler sets unallocated pointers to some default
value. Or Bid is already freed (a common technique in memory
allocators is to fill the deleted value with some pattern in debug
mode to detect this early). Setting values in your case then
accidentally does not crash but modifies the data structure the
garbage pointer happens to point to.

How do you get the instance of Bid ? It is a bit hard to debug your
code without seeing a self-contained snippet that exposes the problem.
In your example, you're using b.set_.... Is 'b' a reference in this
case ? Could it be that you set values on a reference to a temporary
that already is gone ?
Try to run your program with valgrind maybe to find a broken allocation.

(Note it is very very unlikely that the protobuf C++ implementation
has such a bug that is undetected, so something else in your program
is going wrong.)

-h

>
> G.
>
> On Apr 5, 7:54 pm, Henner Zeller <henner.zel...@googlemail.com> wrote:
>> On Thu, Apr 5, 2012 at 01:03, G. <geula.vainap...@mediamind.com> wrot> Hi,
>>
>>
>>
>> > Thanks for responding. This is exactly the way I access the fields.
>>
>> > Code snippet:
>> > ...
>> >        b.set_billableseat("Mediamind");
>> >        b.set_category(5);
>> >        b.set_clickthroughurl("http://www.ynet.co.il";);
>> >        b.set_creativeid("ab15a");
>> > ...
>> > I walked through this with the debugger. When billableseat is set,
>> > Clickthroughurl and creativeId both become "Mediamind" as well. Same
>> > with clickthroughUrl and creativeId - setting each one of them turns
>> > all 3 fields the same value. Only setting Category didn't affect
>> > anything except category.
>>
>> What compiler are you using ?
>>
>> Protocol buffers definitely don't behave this way, so only a very
>> broken compiler or something peculiar in your memory management or
>> other setup can cause this.
>>
>> (IIRC, default values in protobufs share a const instance (in this
>> case: the empty string) for memory reasons, so you would see the same
>> address for the default values, but this is of course disengaged
>> whenever a value is set.)
>>
>> If you just create a simple protocol buffer with two string fields and
>> a simple main() function: do you get the same behavior ?
>>
>> -h
>>
>>
>>
>>
>>
>>
>>
>> > Thanks,
>>
>> > G.
>>
>> > On Apr 4, 7:45 pm, Jeremiah Jordan <jeremiah.jor...@gmail.com> wrote:
>> >> How are you setting the data?
>> >> You should be using something like:
>> >> bid.set_HtmlSnippet("Stuff");
>> >> and
>> >> std::string html = bid.HtmlSnippet();
>>
>> >> See:https://developers.google.com/protocol-buffers/docs/reference/cpp/goo...
>>
>> >> On Wednesday, April 4, 2012 7:25:15 AM UTC-5, G. wrote:
>>
>> >> > Hi all,
>>
>> >> > I am using protobuf 2.4.1, and I encountered a weird issue:
>>
>> >> > I created the following .proto file:
>>
>> >> > message Auction {
>> >> >         // Bid request id
>> >> >         required bytes Id = 1;
>> >> >         optional bytes Ip = 2;
>> >> >         required int32 adId = 3;
>> >> >         required int32 adHeight = 4;
>> >> >         required int32 adWidth = 5;
>> >> >         optional string domain = 6;
>> >> >         optional string country = 7;
>> >> >         optional string region = 8;
>> >> >         required string exchangeUserId = 9;
>> >> >         optional string pageUrl = 10;
>> >> >         optional int32 publisherId = 11;
>> >> >         optional int32 timezoneOffset = 12;
>> >> >         optional string userAgent = 13;
>> >> >         required string identifier = 14;
>> >> > }
>>
>> >> > message Bid {
>> >> >         // Bid request Id
>> >> >         required bytes Id = 1;
>> >> >         required int32 processingTime = 2;
>> >> >         required int32 adId = 3;
>> >> >         required float bid = 4;
>> >> >         required int32 advertiserId = 5;
>> >> >         required string creativeId = 6;
>> >> >         required string billableSeat = 7;
>> >> >         required int32 category = 8;
>> >> >         required int32 vendorType = 9;
>> >> >         required int32 strategyId = 10;
>> >> >         required string clickthroughUrl = 11;
>> >> >         required string HtmlSnippet = 12;
>> >> > }
>>
>> >> > It compiles fine with protoc.exe.
>>
>> >> > However, when I tried assigning the fields, I noticed the following
>> >> > phenomenon: the fields id, billableseat and htmlsnippet in Bid
>> >> > structure share the same address! When one is assigned, so are the
>> >> > other two.
>>
>> >> > What am I doing wrong? Has anyone encountered such a thing before?
>>
>> >> > Thanks,
>>
>> >> > G.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Protocol Buffers" group.
>> > To post to this group, send email to protobuf@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > protobuf+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to 
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/protobuf?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to