My Poor Little Blameless Voron
Join the DZone community and get the full member experience.
Join For Freei’m currently working on a project using voron (although only incidentally), and i was horrified to get the fatalexecutionengineexception that was discussed previously. naturally, i assumed that this is something that i did wrong in voron.
after a lot of work, i managed to narrow it down to… not voron. to be rather more exact, it is voron that is causing it, but it isn’t voron’s fault.
the actual issue is the fact that i’ve accidently using json.net to serialize a stream that i got from voron. and voron is giving us an unmanagedmemorystream. i kept thinking that i was doing something wrong with releasing memory, but as it turns out, here is a very small repro:
unsafe static void main(string[] args) { jsonconvert.serializeobject(new foo { ptr = (byte*)0 }); } public unsafe class foo { public byte* ptr { get; set; } }
and that is enough to get the above mentioned error.
what actually happens is that json.net is using dynamic il generation to optimize accessing properties. and it just doesn’t know how to handle pointer properties. what it ended up doing is to generate invalid il, which resulted in a crash when we tried to actually use it.
nothing to do with voron at all, just a class that has a pointer property that was attempting serialization. nasty bug, and very annoying to try to figure out.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
WireMock: The Ridiculously Easy Way (For Spring Microservices)
-
Using OpenAI Embeddings Search With SingleStoreDB
-
A Data-Driven Approach to Application Modernization
-
Designing a New Framework for Ephemeral Resources
Comments