When using Burst compilation and this following struct inside of a ComponentData/Job, my whole editor crashes. Removing the struct layout fixes this, but I thought that LayoutKind.Explicit was supported for Burst?
[StructLayout(LayoutKind.Explicit)]
public struct UnionValue
{
[FieldOffset(0)]
public float Min;
[FieldOffset(4)]
public float Max;
[FieldOffset(0)]
public uint Property;
}
Yep, we need to know the version first before investigating. If you are not on latest (preview.10) I encourage you to test it first. Layout should work, we have unit tests covering it, but you could have hit an issue.
I’m on the latest of the latest ( 2019.1.0f1, Burst 1.0.0-preview.12 )
Took me a while to pin down the location because it would seem to crash at random during runtime. I noticed that disabling jobs compilation fixed this, then after an hours of debugging I noticed that if I compiled some specific jobs ( the ones that used my explicit layout struct ) through the inspector I would get the same instant editor crash ( the whole editor )
Sorry I couldn’t upload my project, it’s way too complex at this moment, but here’s the case number: (Case 1145230)
If this isn’t enough I could take some time off in the following weeks to see if I can make a simple bug reproduction project.
We can only fix this issue if we are able to reproduce it, so it would help a lot if you could try to isolate what is making the whole compiler crashing (this is pretty rare) and send us a small repro. We have been fixing an issue with the sizeof of struct with explicit layout which could be wrong depending on the cases and it will be available in 1.0.0-preview.13 hopefully this Monday, but I don’t think it is related to your issue
I found that the burst crashes the editor when using readonly collections and writing to them within a bursted IJobChunk.
I know it’s wrong doing that ( I juste forgot to modify them after a change ), but I think it should show an error message instead of crashing or freezing the editor.