protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.3k stars 15.45k forks source link

Call "ConvertMessageToJson" function trigger GOOGLE_DCHECK(target + size == res) #8221

Closed haoziAndy closed 2 years ago

haoziAndy commented 3 years ago

In Linux,When call "ConvertMessageToJson" function trigger GOOGLE_DCHECK(target + size == res) ,Why? But Windwos is ok.

haberman commented 3 years ago

Can you send the error output from the crash? What version of protobuf were you using?

If you can reduce this to a small program that reproduces the problem, we should be able to diagnose and fix it.

Minohh commented 3 years ago

My program has the same issue occasionally when calling SerializeToString, I was wondering what situation would cause this issue

poulls commented 2 years ago

Guess protobuf object might be changed by other thread which happened right after get value of (target + size) and before get value of res for GOOGLE_DCHECK(target + size == res).

deannagarcia commented 2 years ago

Sorry for the long delay here.

If you're still having an issue, please use the bug template to fill in information including what version you're using, how to reproduce, and the error logs.

jorgbrown commented 2 years ago

I concur with poulls: The likely cause is that another thread is modifying the message while your thread is trying to convert it. A related possibility is that somehow, part of the message was free'd or delete'd even though the message still references it; if so, the conversion to JSON might end up using some of that free'd memory, causing an internal inconsistency which this DCHECK is complaining about.