Semi-Random Access Violation in BodyInstance.cpp
I'm currently working on a primarily C++ project in Unreal 4.7.6 that will be built for Android use. Somewhat randomly, either in editor on on the android device, I can receive access violation crashes caused by the GetSimplePhysicalMaterial() function in BodyInstance.cpp, specifically on line 2701: Material->GetPhysicalMaterial();
From the look of the code inspector when the exception is thrown, the material returned by MeshComp->GetMaterial(0); above the triggering line is corrupted in some way (Most pointers are 0xdddddddddddddddd and values are set to their minimum possible value).
This always tends to happen during a SetMaterial, although not always, despite the fact that the same material had been used fine for many previous meshes and (from the inspector's point of view) appears fine outside of SetMaterial. Sometimes I can run the game to completion, while other times it will crash on the main menu. There doesn't seem to be a direct way to reproduce it, although it tends to happen to a class that is regularly spawned. My MaterialInstance and StaticMesh pointers are kept static in the factory class and are not modified by anything and appear valid during the exception break.
In addition, this tends to be more prone after a hot rebuild (in the editors case - there is no correlation I can find in the Android build).
It there a particular way to handle materials that I might be missing. I don't actually need or have any use for physical materials, so if there is a way to flat out avoid that check that would be great. I know this is a haphazard report, but if I discover more on either how to reproduce or what I was doing wrong I will update this question as appropriate.
Hi danm36 -
Can you check your code and insure that the Material that you are setting is not being Garbage collected? Make sure that what you are setting it in the class as a Uproperty and that the Material being set is valid.
answered May 13 '15 at 09:32 PM
Lovecraft_K ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here