ohler55 / oj

Optimized JSON
http://www.ohler.com/oj
MIT License
3.12k stars 250 forks source link

Not initialised stack_buffer #892

Closed dundee closed 11 months ago

dundee commented 11 months ago

Hi, I am sorry for probably very dumb question since I don't know C very well, but we are investigating very weird behaviour of JSON serialisation (data busted randomly) and OJ is the main suspect right now.

Is it ok that stack_buffer is not initialised inside the encode function?

I can see a call to oj_out_init but stack_buffer is not initialised there, it's used right away.

Thanks!

ohler55 commented 11 months ago

It is okay not to be initialized since the pointers to the start of the buffer are set at 0 indicating there is no data in the buffer yet.

Can you give more details about the issue you are seeing?

dundee commented 11 months ago

We can see a random string data being inserted into the resulting JSON string. It happened only in few occurrences though.

I probably get what you mean. The dirty data could be there, but since cur is set to beginning of the array we doesn't care what is further.

ohler55 commented 11 months ago

If you can help me recreate the issue I can get it fixed.

dundee commented 11 months ago

Closing. If I am able to reproduce it, I will post more details. Thank you!

dundee commented 11 months ago

We have found out that the problem was not limited to OJ serialisation. It was a general data corruption issue caused by faulty HW node.

ohler55 commented 11 months ago

Glad you figured it out. Glad it wasn't Oj as well. 😄