x

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"

Crash: UPrimitiveComponent::UpdateOverlaps accessing Array of length 0

Heya,

In my code, at one point I call SomeChildActor->ChildActor->SetActorEnableCollision(false);

This causes a crash because the UpdateOverlaps functions some time down the chain accesses an array of 0 length, as seen in this debug screenshot:

alt text

I solved it on my end by adding a Num() check beforehand, but you might have a different solution in mind.

Best regards, Damir H.

Product Version: UE 4.7
Tags:
crash.png (160.9 kB)
more ▼

asked Jun 10 '15 at 08:29 AM in Bug Reports

avatar image

DamirH
589 22 23 41

avatar image Acrossfy Jun 10 '15 at 11:21 AM

As I know UPrimitiveComponent::UpdateOverlaps method was changed in 4.8. Most probably this bug is already fixed. Try the latest 4.8 preview build to check it out. Please let me know when you check it

avatar image DamirH Jun 10 '15 at 11:56 AM

Heya,

Thanks for the info, I'll be sure to check it out.

avatar image Tim C ♦♦ STAFF Jun 16 '15 at 10:36 PM

Hi DamirH,

I tried to reproduce the issue that you described but was unable to do so. Were you able to try this in 4.8 and saw the same results? If so, could you provide more information about how you are setting this up?

Tim

avatar image DamirH Jun 17 '15 at 01:03 AM

Yup, I managed to reproduce it (This time, OverlapIdx was 4, ArrayNum was 0). There is a very specific series of steps and conditions I do to reproduce it so hopefully this'll help you narrow it down. Throughout the text I will add code snippets and I'll group them into pastebins with relevant, but not necesarily same-file information.

First of all, the context is enemies wielding weapons and me disabling collision on those weapons when the enemy dies. The weapons can be melee or ranged, and are child actor components.

Perhaps significant is the fact that I create and populate those child actors via the construction script, as seen here.

Now, my ranged weapons have a child actor component which is the projectile (So basically my enemy's child actor has a child actor). I set that to any object of the ProjectileBase class in my blueprint. The ProjectileBase header and implementation can be seen here.

Now, when my enemy dies and goes into ragdoll, I don't want him flailing around because he's colliding with his own weapon. This is the code snippet that turns off the weapon collision.

The error happens at line 12 - trying to turn off the collision of the projectile, but only, and only if the ranged weapon / projectile overlaps the melee weapon. I accidentally forgot to attach them both to the right hand and the bug didn't occur - if they don't overlap, nothing bad happens.

I hope this is enough for you to replicate it, or at least get a better understanding. Let me know if I can help in any other way.

avatar image Tim C ♦♦ STAFF Jun 18 '15 at 04:12 PM

Thanks for providing the code you are using. I am attempting to get a project to build using your code (there are some references to code that wasn't provided, I need to comment out those references and make sure it still works correctly to reproduce the issue), and then will try to simplify the project as much as possible while still reproducing the issue.

Would it be possible to get the callstack provided by the crash reporter when running the project in the Editor?

Tim

avatar image DamirH Jun 18 '15 at 04:31 PM

Hey Tim,

Unfortunately I am also sporting this awesome bug: https://answers.unrealengine.com/questions/241024/48-no-debug-symbols-in-crash-report.html

But VS should provide the stack at the time of a break so it should be fine, I'll get to it first thing in the morning when I get back to the office. Alternatively if the build I have at home can reproduce the bug I can have the stack in an hour.

Also, given the referenced code (I only included relevant bits) I will try and make a small project that just replicates the bug for you. Will get back asap.

Edit: Also if you mean the weapon component code, I included pastebin links to those at the bottom of the first link. Here they are:

Melee weapons .h: http://pastebin.com/7vCebmeA Melee weapons .cpp: http://pastebin.com/WgkRCWT6

Ranged weapons .h: http://pastebin.com/0zx7vjy2 Ranged weapons .cpp: http://pastebin.com/FfmVS0zu

avatar image DamirH Jun 18 '15 at 05:42 PM

Hey Tim,

Creating the test project might take a bit, but here's the callstack: http://pastebin.com/VdVMSXSH Line 349 in ProcessDamage is line 12 in the last code snippet I provided in my original explanation.

Also, for what it's worth I personally think this can be traced down to ChildActorComponent, it's always been an odd beast and I am using it in a very colorful manner.

Best regards, Damir H.

avatar image Tim C ♦♦ STAFF Jun 19 '15 at 01:54 PM

I believe I am very close to completing the set up to reproduce this issue, but have one more question. How have you declared the Weapons array that you are iterating through in the loop that is causing the crash? The initial declaration I used for that array did not allow me to actually specify any weapons in the Blueprint I created from the enemy class.

Tim

avatar image DamirH Jun 19 '15 at 02:26 PM

Hey Tim,

Sorry for leaving that out. I imagine you're talking about the Weapons array found in this snippet. That is actually a Map. Here's a pastebin with comments on how it's all done.

It's a tad bit convoluted, I hope this doesn't throw you off too much. Basically, Weapons is a map so that I can quickly access the weapons with a GetWeapons(FWeaponSlot Slot) function. The FWeaponSlot is just the socket it attaches to + whether it's melee or ranged. Having the weapons in a map speeds up accessing like this.

The map itself is initialized by the CombatComponent (where all of this resides), but the caller for the InitializeWeapons() function is the EnemyCharacter, as you can see that weapons require the owner's skeletal mesh to initialize (so they know where to look for their respective attach socket.

avatar image DamirH Jun 25 '15 at 08:59 PM

Hey Tim, any news on this? Did you manage to get the project running?

avatar image Tim C ♦♦ STAFF Jun 29 '15 at 03:17 PM

Sorry, I got involved in a few other issues. I'm hoping to be able to get back onto this later today or tomorrow.

Tim

avatar image Tim C ♦♦ STAFF Jul 08 '15 at 03:11 PM

Last week turned out to be a bit crazy for me, and this week doesn't look much better. I did have some time to look into this again yesterday, and I still think I'm close, but I am still missing some little thing that will allow me to reproduce the issue.

Would it be possible to take a look at the entire project? If I can see it happening in your project, I may be able to work backwards from there to determine where the issue is coming from.

Tim

avatar image DamirH Jul 08 '15 at 03:56 PM

Hey Tim,

I just talked to my higher ups and I can send you a striped down version with the bug through a private channel if that's ok. If you can give me an email address to send the link to I can have the build by tomorrow morning.

Best regards, Damir H.

avatar image Tim C ♦♦ STAFF Jul 08 '15 at 07:14 PM

If you have a private DropBox, Google Drive, or similar that you can upload a zip file to, you can send me a link via private message on the forums.

If that isn't possible and you need to attach a zip file directly to an email, go ahead and send me a PM on the forums and let me know, and I will get you my email address.

Tim

avatar image DamirH Jul 08 '15 at 09:50 PM

I'll put it up on Dropbox and PM you as soon as it's up.

Best regards, Damir H.

avatar image Tim C ♦♦ STAFF Jul 09 '15 at 08:26 PM

Thank you for providing the test project. I have been able to narrow down where the the issue is occurring. Now I just need to figure out why this is happening with the particular setup that you are using with the character.

Tim

avatar image DamirH Jul 09 '15 at 09:06 PM

Wooo! Progress! I feared the whole day that you might not be able to reproduce it. I think I am the only person in the world who had this issue. :P

avatar image Tim C ♦♦ STAFF Jul 09 '15 at 09:49 PM

I was able to reproduce the issue right away. I think it is just that you have a very unique character set up, and you are perhaps doing something we had not anticipated. I spent a big chunk of today slowly working through the source code that is being run to find out where things were going wrong. Now that I know roughly where that is happening, I am hoping I can start picking stuff apart to find out why it is going bad in this case.

Tim

avatar image DamirH Jul 09 '15 at 11:28 PM

I wasn't aware that my setup was that exotic. Am I perhaps doing something wrong?

avatar image Tim C ♦♦ STAFF Jul 10 '15 at 12:50 PM

I don't believe you are doing anything "wrong." I suspect that you are just setting up the character in a way that we didn't expect, so the source code doesn't handle the situation the way you expect it to. And a crash is certainly not the way we expect it to handle the situation. This is one of the unfortunate side effects of developing any kind of software. As soon as you give it to people to start using, they start doing things with it that were never anticipated or planned for. Sometimes it works out fine, sometimes you get really strange behavior or crashes.

I most likely won't be able to put much time into this issue today, but I am hoping to at least get started with narrowing it down.

Tim

avatar image DamirH Jul 10 '15 at 01:01 PM

There is no rush whatsoever, we are in over our heads with completely differeny things now. Good luck!

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

1 answer: sort voted first

Hi DamirH,

With the help of an extra pair of eyes, I believe I was able to track down where things were going wrong and causing the crash you were experiencing. The character setup that you are using is fine, and actually was a bit of a false trail. The actual culprit lies in the OnOverlapEnd() function of your ProjectileBase class. While turning off the collision on your character's weapons, the Engine loops through all of the overlapping actors and turns off collision for them one at a time. However, towards the end of that process the OnOverlapEnd() function is being called by a delegate and that is where things go wrong.

The process the Engine goes through when turning off collision for overlapping objects is to generate a TArray of all overlapping objects. It then starts with the last element of the array and loops through the array by turning off collision on the last element and removing it from the array, then decrementing the loop index. This would normally work fine, except when the OnOverlapEnd() function is called, an extra element ends up being removed from the array which results in the loop index looking for an array element that is now out of bounds. When I commented out the code you have in OnOverlapEnd(), there was no crash and the character rag-dolled as expected. I suspect that you just need an extra check in this function to see if it is being called due to normal use of the projectile, or because the character is now dead.

Tim

more ▼

answered Jul 20 '15 at 07:11 PM

avatar image DamirH Jul 20 '15 at 08:01 PM

I must admit I am baffled. When I read your reply I facepalmed, realizing I completely forgot that my ProjectileBase has an OnOverlapEnd()... but when I sat down on my PC and saw the function I was left with just bewilderment... because the only thing I do there is turn collision ON (for when my projectile leaves my enemy, to begin colliding with it).

Needless to say, I am a bit confused. I will however add a check to that function to make sure the owner of the weapon is alive and / or if the projectile is being fired.

I cannot express how much your help on this is appreciated, and I can only imagine the frustration you went through to get to the bottom of it. Subsequently, I can't thank you enough for going through all the trouble. Terrific job and my utmost gratitude and highest of fives to both you and your second pair of eyes.

Best regards, Damir H.

avatar image Tim C ♦♦ STAFF Jul 21 '15 at 02:58 PM

Admittedly, delegates is a bit of a weak area for me. I was able to trace things through to where the delegates were being called, and noticed that that seemed to be where things were going bad. That was why I wanted to get another set of eyes looking at it to help me track it through the delegate calls.

The process that I was describing earlier about the Engine looping through the overlapping components, turning off collision, then removing the component from the array happens in UpdateOverlaps() in the UPrimitiveComponent class. When you turn the projectile's collision on in OnOverlapEnd(), the code goes through UpdateOverlaps() again. This ends up clearing out the overlap array that the loop is still using.

Now that I know what was causing the crash, I am hoping to find some time to put together a simplified example of the crash that we can use to find a way to guard against this in the source code.

Tim

avatar image DamirH Jul 21 '15 at 03:01 PM

Oh, now I understand! Thank you so much for clearing that up. Wow... I must admit this was probably the most obscure bug I have ever encountered / caused. You're a champ Tim! I hope this didn't give you too much of a headache at work, and I hope that at least something good will come out of this (the source code safeguard) so that it wasn't in vain. :P

Thank you!

(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