Crash Unity

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Crash Unity

Postby pysnoo » Mon Oct 22, 2018 10:37 am

Hello,

I'm trying to get a project working with NewtonDynamics in Unity but I got some crash.
I'm making a test project with minimal things to see if you can help me.

The first crash I got was when I unload my scene and all my NewtonBodies are destroyed. I got a crash when destroying collider shape.

In my test project I already got a crash when creating CollisionBox.
You can open the project, launch scene called "Entry" and in play mode push Space Key and you will got a crash because I'm trying to create a lot of newton bodies.
It crash in :
0x00007FFB9892FCFF (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFB98923DC8 (NewtonWrapper) CSharp_new_dNewtonCollisionBox
0x00000000307981E8 (Mono JIT Code) (wrapper managed-to-native) NewtonWrapperPINVOKE:new_dNewtonCollisionBox (System.Runtime.InteropServices.HandleRef,single,single,single)

I'm using last version in gitHub.

Link for project : https://we.tl/t-sFZLjkz13G
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Tue Oct 23, 2018 2:41 am

Hi.

Got a crash as well which seems to happen due to the collider being passed a null ptr instead of the world.

I changed the line
Code: Select all
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsync(0);

to
Code: Select all
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsync(0, UnityEngine.SceneManagement.LoadSceneMode.Additive);

LoadSceneAsync seems to unload the previous scene unless you add the Additive param.

If the Entry scene goes the world would be destroyed as well.
Don't really understand though why there wasn't a C# null ptr exception and how it could reach the native constructor with a null ptr.
It could be that the native world was destroyed but the managed world instance was lingering, therefor no null ptr exception in the C# code.

I'll guess we need to add a check for that.
[EDIT]
Just added some null reference checks so the Editor console should now display a NullReferenceException instead of crashing.

[EDIT]
An alternative way if you want the entry scene to unload is to make the World object stay alive by adding this at the end of the awake function in the entry script
Code: Select all
        DontDestroyOnLoad(m_newtonWorld.gameObject);
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Tue Oct 23, 2018 4:46 am

Thank you for watching my issue.
Yes I missed to add Additive when loading, sorry for that.

I just upload a new version of the project. You can play it, and alternate between Space key and R key.
Space will load the scene Empty with a lot of newtonBodies and R will unload the scene and destroy them.

Try multiple time to do that and you will have the crash when destroying bodies and BoxColliders

https://we.tl/t-WS2igR7k5Z
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Tue Oct 23, 2018 5:49 am

Hmm, got a crash once(or rather an assert) saying something about separationDistance being zero.
Then I tried again but can't get the error to reappear. Tried loading(and unloading) the scene hundred of times but can't get it to crash.

I see that you randomly position 200 bodies(with compound collider). Do you get a crash if you position them so that they can't overlap at start, like a grid for example?
If the positions are randomized it can happen that several bodies start inside each other. I'm thinking that could be the reason for the assert.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Tue Oct 23, 2018 6:04 am

No, I'm not searching if bodies will overlap before instantiating them.
I tried again and got a crash only by doing 3 times (Space - R)
You can also have the crash if you just do Space (Scene empty is loaded) and then just click Play on Unity to stop simulation, it will crash too.

0x00007FFEC61F2C03 (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFEC61CF808 (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFEC61CF33D (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFEC61D0D88 (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFEC61D121C (NewtonWrapper) CSharp_dNewtonJointBallAndSocket_SWIGUpcast
0x00007FFEC61C524D (NewtonWrapper) CSharp_delete_dNewtonCollisionCompound
0x0000000036018014 (Mono JIT Code) (wrapper managed-to-native) NewtonWrapperPINVOKE:delete_dNewtonCollisionCompound (System.Runtime.InteropServices.HandleRef)
0x0000000036017CA9 (Mono JIT Code) [C:\CHA_dynamics\NewtonUnityPlugin\NewtonPlugin\newton_wrap.cs:3143] dNewtonCollisionCompound:Dispose ()
0x00000000360178F4 (Mono JIT Code) [C:\CHA_dynamics\NewtonUnityPlugin\NewtonPlugin\NewtonBodyCollision.cs:95] NewtonBodyCollision:Destroy ()
0x0000000036016449 (Mono JIT Code) [C:\CHA_dynamics\NewtonUnityPlugin\NewtonPlugin\NewtonBody.cs:113] NewtonBody:DestroyRigidBody ()
0x0000000036015B8F (Mono JIT Code) [C:\CHA_dynamics\NewtonUnityPlugin\NewtonPlugin\NewtonBody.cs:47] NewtonBody:OnDestroy ()
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Sweenie » Tue Oct 23, 2018 6:07 am

Now i managed to get a crash and it happened when destroying the bodies as you mentioned.

Not sure why it crashes though... Maybe Julio can shed some light on this.

Exception (Unhandled exception thrown: write access violation. instance was 0x36998000.)
Image

Call stack
Image

Autos
Image
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby Slick » Tue Oct 23, 2018 7:13 am

I'm not using Unity but it seems weird to me that there would be a call to setuserdata on destruction. That is just a pointer for your use.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Crash Unity

Postby Sweenie » Tue Oct 23, 2018 9:51 am

Yes, considering that the next call is NewtonDestroyCollision() which will destroy the collider so setting the userdata to NULL isn't really necessary.
But either way, the crash seem to indicate that the collider has been deleted which I don't understand since NewtonDestroyCollider hasn't been called yet.

Unfortunately this happens seemingly at random so it will be difficult to track this bug.
Unless I can reproduce the error easily.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Crash Unity

Postby pysnoo » Tue Oct 23, 2018 10:07 am

I am able to reproduce this bug easily by juste pressing Play, press Space key and when all bodies are instanciated, juste press Play again.

Do you know if it can be fixed quickly (if Julio here ?) since this is a very big problem for my project.
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Julio Jerez » Tue Oct 23, 2018 10:49 am

the problem with unity is that I do not know how to run these projects, every person seems to make project in different ways.
I see tow folder assets, and project settings how to do I test it?

when I run unity and I select open or new I do not see what file to open is only show folder and as I click they selected folder is no unity project.
Thats not how the demos are launched, the demo in teh plug in.
this is what I see
Untitled.png
Untitled.png (43.29 KiB) Viewed 7947 times
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby pysnoo » Tue Oct 23, 2018 11:33 am

Choose Open project at launch of Unity and browse to the repository containing folders Assets and ProjectSetting (CrashTest I think) and just click Select folder wich will appear at bottom of window
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Julio Jerez » Tue Oct 23, 2018 12:10 pm

I know people has tell me to do the same before, but. not matter what I do unity always say this is not a unity project. the only time I have been able to run a repro is when I copy some file from the asset to the asset in the plugin, but this seem to be different each time.
till this day I have not being able to test a single unity repro, regardless how I search for them, this is totally ridiculous.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby pysnoo » Tue Oct 23, 2018 12:20 pm

The message "Selected folder is not a unity project" is the one I can see on your screenshot ?

You got the same one with just one folder before ? ("This PC/Downloads/CrashTest/CrashTest") ?
pysnoo
 
Posts: 24
Joined: Mon Oct 08, 2018 9:08 am

Re: Crash Unity

Postby Julio Jerez » Tue Oct 23, 2018 2:21 pm

I'w try tonight and see.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash Unity

Postby Julio Jerez » Tue Oct 23, 2018 11:36 pm

Ok I opened the project, but I do no see anything, only an empty screen with a camera.

is there anything I need to do?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 2 guests

cron