> HTMud::EnvAdd item;
> item.set_id(ID);
> item.set_idtype(typeID);
> item.set_x(X);
> item.set_y(Y);
> item.set_z(Z);
> item.set_lockdown(lockdown);
> item.set_mapid(map);
> item.set_tilesetno(tilesetNo);
> item.set_tilesetx(tilesetX);
> item.set_regionx(regionX);
> item.set_regiony(regionZ);
Are all these values primitives? Are any of them protocol buffers?
Have you tried dumping the values that are being set when it dies, and trying a standalone program that sets the values and calls SerializeToString to see if it has the same problem?
Have you made any changes to the protocol buffers library? I'm assuming you are using the released version of 2.4.1?
Have you tried running this under valgrind? I'm wondering if there could be other weird memory corruption that is happening? That seems to be a frequent cause of "this shouldn't be happening" type errors, particularly things that appear/disappear occur with optimization enabled/disabled.
Evan
Ah! Interesting. So one of your .set_* properties is a boolean, and one of them was uninitialized? That would do it. This was discussed previously and dismissed as a "wont fix" problem, because it is hard/impossible to make portable code that will test for this:
http://code.google.com/p/protobuf/issues/detail?id=234
Although its somewhat confusing since WireFormatLite::WriteBoolNoTag contains code to try to avoid this problem, which GCC helpfully optimizes away.
I am not able to get the exact crash as the one you reported, but I can get it to crash in MessageLite::SerializeWithCachedSizesToArray by creating a boolean with a value of 0x80 (serializing to two bytes instead of one, causing it to create a message larger than it expects). I can't figure out how it could crash at the point you report the crash, but that doesn't really matter.
Glad you got it working,
Evan