fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
180 stars 42 forks source link

seg fault when i parse required bytes field #3

Closed AlexMarlo closed 11 years ago

AlexMarlo commented 11 years ago

i have package message;

message Notification { required string date = 1; required bytes message = 2; } where message is another nested serialized proto message

on parse first parse is ok but when i parse nested message i have seg fault when i use npm project "protobuf" everything is ok

fuwaneko commented 11 years ago

I'm not sure what you're trying to do. Could you clarify a little bit?

AlexMarlo commented 11 years ago

i've sent you pull request wich fix this bug https://github.com/fuwaneko/node-protobuf/pull/5

AlexMarlo commented 11 years ago

looks like there is incorrect work with bytes fields while serialization and parse

fuwaneko commented 11 years ago

So, why are you trying to serialize one message and put serialized data inside another? You could just do

message B {
...
}
message A {
    required B message_b = 1;
}

As for serializing node.js Buffers I don't think node-protobuf should do this, it's aim is to work with plain simple objects. But if it's trivial to implement, I'll add this functionality.

AlexMarlo commented 11 years ago

i showed only little problem for real we have very big hierarchy when Message is root and in one nested object it should store Message it self thats why we chose to store it as serialized object to avoid circular dependency

fuwaneko commented 11 years ago

Ah, that's a good reason, I didn't think about such scenario. Anyways, your pull request is merged, so you can close this issue if it's solved.

AlexMarlo commented 11 years ago

thanks, it also will be very good, if you'll update package in npm repo ASAP ))

fuwaneko commented 11 years ago

@AlexMarlo Just updated npm.

AlexMarlo commented 11 years ago

Big Thanks)