mbraceproject / FsPickler

A fast multi-format message serializer for .NET
http://mbraceproject.github.io/FsPickler/
MIT License
325 stars 52 forks source link

Crash pickling a discriminated union in release build #102

Closed jmazar closed 6 years ago

jmazar commented 6 years ago

I currently have a discriminated union that pickles without any hiccups in debug mode using a BinarySerializer but when I build in release my program crashes when I go to pickle it.

My types look like

  type BBO = {
        Exchange : string;
        Symbol : string;
        BidPrice : decimal;
        BidSize : decimal;
        AskPrice : decimal;
        AskSize : decimal;
    }

    type MarketMessage = 
        | MarketData of BBO

And when I run this code in release it crashes. Works fine in debug.

    let pickler = FsPickler.CreateBinarySerializer()
    let m = {Exchange = "CME"; Symbol = "GEU8"; BidPrice=101m; BidSize=1m; AskPrice=102m; AskSize=1m}
    let message = MarketData m
    let bytes = pickler.Pickle<MarketMessage> message

This is with a .net core f# console project. I have to use version 5.0.0 of your library because I cannot upgrade Fsharp.core past 4.2.0 (or at least I can't find a way) and 5.1.0 requires Fsharp.core 4.3.2.

eiriktsarpalis commented 6 years ago

I can't reproduce with the latest version. What is your stacktrace?

jmazar commented 6 years ago

Hi @eiriktsarpalis , thanks for your quick response. After a bit more digging I found that it was an issue elsewhere in my code that was causing the crash later on. Sorry for bothering.