fast-serialization: Random Deserialization Problem with fst 2.57

We are using fast-serialization now for over a year in our application and it worked like a charm. But with the last version deployed this week, we switched from version 2.47 to 2.57. Everything worked fine in our QA enviroment. But in Production things got weird.

Basically we use the library to serialize and deserialize sessions to and from a Relational DB. In PROD the deserializing produces strange results in some cases. Mostly a java.lang.String.equals call failed inside the string class at line 982 int n = value.length;. The internal value field of the String was null. This should never happen. Except when you mess up the String with reflection. But we were pretty sure we don’t do this 😉 It went that far, that the jvm terminated with a Sementation Error when such maleformed data was accessed.

I wrote a small programm that checked every session in the database. And there where indeed some sessions that failed. I removed them and let the program run again. But wait…now other sessions, that where valid in the first run, failed in the second run. But the binary data was exactly the same 😲

Now we had the idea to try it with the older version 2.47 we used before. And what should I say. The same sessions, written with version 2.57, could be read with version 2.47 without any problem. So the problem must lay in the deserialization logic of fst 2.57.

I tracked it down now to a set of 3 Session objects. When they are deserialized in a specific order, the deserialization does pretty weird stuff for the last sesison object. Most noticalbe it sets a field of type “String” to a List of other Objects.

Some things to note

  • Happens on Windows 10 and Linux systems
  • Reproducable on oralce jdk 1.8_181-x64 and
openjdk version "1.8.0-adoptopenjdk"
OpenJDK Runtime Environment (build 1.8.0-adoptopenjdk-_2018_05_19_00_59-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
  • We use fst on a server and use a ThreadLocal like suggested by the docs private static final ThreadLocal<DefaultCoder> CODERS = ThreadLocal.withInitial(() -> new DefaultCoder()); But my test Testcase shows that it also happens in a simply main class without any threads and also with FSTOBjectInput Instances obtained by the FSTConfiguration. As long as you reuse a Instance it might happen from time to time.

TestCase

~I have a TestCase ready. But I have to make sure first, that I’m allowed to upload it to github as it contains code written for our project at work. I will update this issue as soon as I have uploaded the test case.~ The test case including a description is available at https://github.com/furti/fst-deserialization-problem

But maybe someone has the same Problem or has an idea what could be the cause for this strange behaviour? I’m pretty sure it must be something in the library. But it could also be something we do wrong. So excuse me if that is the case 😃

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 3
  • Comments: 29 (1 by maintainers)

Most upvoted comments

@tlamr

The big attraction with FST was that it’s performance compared to std java serializer was so much better - size of streams are tiny and speed of serialization/deserialization is soooo much faster plus combine this with the fact that your standard java classes work “out of the box” with FST meant it was a real winner.

So far in our evaluations we haven’t found any other solution (other than std java serializer) that doesn’t require changes to our code base or the addition of new “meta data” files to make these other codecs work.

So we’re stuck between a rock and a hard place just hoping that FST will get a fix soon-ish…

On 15/12/2019 1:06 am, tlamr wrote:

I switched it to std java serializer, since this one worked out of the box for the whole app and we needed some asap fix. It seems that we would need to do some changes to be able to use other codecs (kryo4 wanted no arg constructors, json based also wanted some additional things,…) I plan to investigate it further, but so far haven’t dig into it.

@chrisco484 https://github.com/chrisco484 How is going the evalutation of alternatives? Any preference to some other codec?

I fully agree with your view on correctness and speed, we are in the very same situation it seems 😃

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RuedigerMoeller/fast-serialization/issues/270?email_source=notifications&email_token=AAHKEP37DMR5SGV2HEAKCBTQYTSAFA5CNFSM4GHOEYLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4DJUQ#issuecomment-565720274, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHKEP3QMPBCFGBCSSWA72DQYTSAFANCNFSM4GHOEYLA.