Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.



Product Version: UE 4.7
more ▼

asked May 13 '15 at 02:19 PM in Bug Reports

avatar image

10 3 3 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

Thank You

Eric Ketchum

more ▼

answered May 13 '15 at 09:32 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 737

avatar image danm36 May 14 '15 at 04:26 PM

Adding UProperty and removing static appears to have made it work. I'm going to blame Visual Studio's inspector for appearing to show valid data when I moved up the call stack. Thanks!

Just another question regarding UProperty. Does adding UProperty add or otherwise handle the variable with regards to the garbage collector? I didn't add UProperty as I didn't have the need to access those variables from within the editor (I assumed UProperty handled the editor bindings).

Thanks again!


avatar image Doug E ♦♦ STAFF May 21 '15 at 05:43 PM

Hey danm36-

Along with exposing the variable to the editor so it can recognize it, using UPROPERTY does control garbage collection for the variable to make sure that all housekeeping tasks related to it are completed before the object is deleted/removed


Doug Wilson

avatar image danm36 May 22 '15 at 09:28 PM

Excellent, thank you for the help!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question