RomanZhu / Entitas-Sync-Framework

Networking framework for Entitas ECS. Targeted at turnbased games or other slow-paced genres.
MIT License
165 stars 20 forks source link

Crash on macOS #4

Closed odiukov closed 4 years ago

odiukov commented 4 years ago

Hi, I've tried to run SampleScene from this repo without any changes on macOS, it starts the scene, but when I click Setup Server and then Start - it throws me out from Unity (same with the client)

Unity 2017.1.0f2, I've tried using mono, Net Standard, Net 4.X and IL2CPP.

RomanZhu commented 4 years ago

Do you have any logs?

odiukov commented 4 years ago

Refreshing native plugins compatible for Editor in 0.50 ms, found 1 plugins. Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.dylib Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.so Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.dylib Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.so Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.dylib Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle.so Fallback handler could not load library /Applications/Unity/2019.1.0f2/Unity.app/Contents/Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Receiving unhandled NULL exception Obtained 5 stack frames.

0 0x007fff581a8d6d in _platform_memmove$VARIANT$Haswell

1 0x007fff580716cc in inet_ntop6

2 0x00000144ac47cf in enet_address_get_host_ip

3 0x00000150cba40a in (wrapper managed-to-native) ENet.Native:enet_address_get_host_ip (ENet.ENetAddress,System.Text.StringBuilder,intptr) {0x7fdee6728a78} + 0x34a (0x150cba0c0 0x150cba543) [0x148c1dc80 - Unity Child Domain]

4 0x00000150cb9fb3 in ENet.Address:GetIP () {0x7fdee67229e8} + 0x1b3 (0x150cb9e00 0x150cba0ab) [0x148c1dc80 - Unity Child Domain]

Launching bug reporter

I get it even after select macOS at Platform settings in enet and libnet dlls

RomanZhu commented 4 years ago

I'll talk to the author of that lib tomorrow

nxrighthere commented 4 years ago

@AlexanderDykov

  1. The framework utilizes the old version of ENet, the latest version is available here (probably Roman will update it soon).
  2. You are using Unity 2017.1.0f2 where interoperability might be buggy, it's highly recommended to upgrade to 2018.3.5f1 or even better 2019.
  3. The minimal supported version of macOS is 10.12 or higher.

According to logs, it seems that the address or its internal data was freed before it passed the function for obtaining an IP address.

odiukov commented 4 years ago

@nxrighthere Hi, thank you. I made a typo, I was using Unity 2019.1.0f2 (also trying with Unity 2019.1.14f and 2019.2.14) and got the same crash with all these versions, I will try to update ENet today

odiukov commented 4 years ago

@nxrighthere same crash with latest version of ENet

RomanZhu commented 4 years ago

Can you give logs for a crash with latest ENet?

odiukov commented 4 years ago

@RomanZhu Frameworks/Mono/lib/libAssets/Plugins/ENet/enet.bundle Receiving unhandled NULL exception Obtained 40 stack frames.

0 0x007fff5aebbd6d in _platform_memmove$VARIANT$Haswell

1 0x007fff5ad846cc in inet_ntop6

2 0x0000014ce35336 in enet_address_get_ip

3 0x00000153364ecd in (wrapper managed-to-native) ENet.Native:enet_address_get_ip (ENet.ENetAddress,System.Text.StringBuilder,intptr) {0x7fd58e389cd0} + 0x15d (0x153364d70 0x153364fc4) [0x14a477320 - Unity Child Domain]

4 0x00000153364c73 in ENet.Address:GetIP () {0x7fd58e3847e8} + 0x1f3 (0x153364a80 0x153364d5b) [0x14a477320 - Unity Child Domain]

5 0x000001533647fb in Sources.Networking.Server.ServerNetworkSystem:StartServer (ENet.Address) {0x7fd58e37f1c8} + 0xfb (0x153364700 0x153364a4d) [0x14a477320 - Unity Child Domain]

6 0x00000153289c33 in GameController:OnGUI () {0x7fd58ef2f328} + 0xc33 (0x153289000 0x15328b914) [0x14a477320 - Unity Child Domain]

7 0x0000015451fe28 in (wrapper runtime-invoke) object:runtime_invoke_voidthis (object,intptr,intptr,intptr) {0x7fd5959c6fb8} + 0x168 (0x15451fcc0 0x15452000a) [0x14a477320 - Unity Child Domain]

8 0x00000149cdd77c in mono_jit_runtime_invoke

9 0x00000149e9ef0d in do_runtime_invoke

10 0x00000149e9ee6b in mono_runtime_invoke

11 0x0000010fe5a09d in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)

12 0x0000010d2dbd91 in MonoBehaviourDoGUI(int, ObjectGUIState&, MonoBehaviour::GUILayoutType, int, ScriptingMethodPtr, PPtr)

13 0x0000010fe03ff5 in MonoBehaviour::DoGUI(MonoBehaviour::GUILayoutType, int, int)

14 0x0000010d2d2417 in GUIManager::DoGUIEvent(InputEvent&, bool)

15 0x0000010d2d2bee in GUIManager::SendQueuedEvents()

16 0x0000010d2d1512 in GUIManager::InitGUIManager()::PreUpdateIMGUISendQueuedEventsRegistrator::Forward()

17 0x0000010f801f4e in ExecutePlayerLoop(NativePlayerLoopSystem*)

18 0x0000010f801fba in ExecutePlayerLoop(NativePlayerLoopSystem*)

19 0x0000010f802202 in PlayerLoop()

20 0x0000010e1c2d20 in PlayerLoopController::UpdateScene(bool)

21 0x0000010e1b7337 in PlayerLoopController::UpdateSceneIfNeeded()

22 0x0000010e1b4dc9 in Application::TickTimer()

23 0x00000110ef2d25 in -[EditorApplication TickTimer]

24 0x007fff31055ceb in __NSFireTimer

25 0x007fff2edc8a60 in CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION

26 0x007fff2edc860c in __CFRunLoopDoTimer

27 0x007fff2edc8152 in __CFRunLoopDoTimers

28 0x007fff2eda9362 in __CFRunLoopRun

29 0x007fff2eda88be in CFRunLoopRunSpecific

30 0x007fff2e09496b in RunCurrentEventLoopInMode

31 0x007fff2e0946a5 in ReceiveNextEventCommon

32 0x007fff2e094436 in _BlockUntilNextEventMatchingListInModeWithFilter

33 0x007fff2c42e987 in _DPSNextEvent

34 0x007fff2c42d71f in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]

35 0x007fff2c42783c in -[NSApplication run]

36 0x007fff2c416d7c in NSApplicationMain

37 0x00000110f319ac in EditorMain(int, char const**)

38 0x00000110f31c79 in main

39 0x007fff5acd33d5 in start

Launching bug reporter

nxrighthere commented 4 years ago

@AlexanderDykov Can you try to run this test for Unity with just ENet? Copy-paste the code into Test.cs file, attach it to an empty gameobject in a scene, hit play, and then look at the console.

odiukov commented 4 years ago

@nxrighthere Same error here with Test-script

Receiving unhandled NULL exception Obtained 17 stack frames.

0 0x007fff61225d6d in _platform_memmove$VARIANT$Haswell

1 0x007fff610ee6cc in inet_ntop6

2 0x00000148a82336 in enet_address_get_ip

3 0x00000148a82488 in enet_address_get_hostname

4 0x0000014d90f79d in (wrapper managed-to-native) ENet.Native:enet_address_get_hostname (ENet.ENetAddress,System.Text.StringBuilder,intptr) {0x7fbc55eaf3d8} + 0x15d (0x14d90f640 0x14d90f894) [0x14a03fc80 - Unity Child Domain]

5 0x0000014d90f543 in ENet.Address:GetHost () {0x7fbc55ea9f48} + 0x1f3 (0x14d90f350 0x14d90f62b) [0x14a03fc80 - Unity Child Domain]

6 0x0000014d90c2ab in Test:Server () {0x7fbc553ce208} + 0x4fb (0x14d90bdb0 0x14d90e853) [0x14a03fc80 - Unity Child Domain]

7 0x0000014d46b456 in System.Threading.ThreadHelper:ThreadStart_Context (object) {0x7fbc4a3badf0} + 0x146 (0x14d46b310 0x14d46b561) [0x14a03fc80 - Unity Child Domain]

8 0x0000014d469703 in System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) {0x7fbc4a3bbc40} + 0x93 (0x14d469670 0x14d469741) [0x14a03fc80 - Unity Child Domain]

9 0x000001464ae77c in mono_jit_runtime_invoke

10 0x0000014666ff0d in do_runtime_invoke

11 0x0000014668d3bf in start_wrapper

12 0x00000146701114 in GC_inner_start_routine

13 0x000001467010a9 in GC_start_routine

14 0x007fff612312eb in _pthread_body

15 0x007fff61234249 in _pthread_start

16 0x007fff6123040d in thread_start

Launching bug reporter

odiukov commented 4 years ago

It crashes on this line: address.GetHost()

if I comment this Debug.Log("[Server] Host: " + address.GetHost());, then everything works fine and I'am getting: [Server] Test successfuly completed...

nxrighthere commented 4 years ago

That's interesting, thanks. I think I need to find a machine with macOS to resolve this...

nxrighthere commented 4 years ago

@AlexanderDykov Try to replace ENet.cs with this one [Link removed]

odiukov commented 4 years ago

@nxrighthere yes, it works fine right now

nxrighthere commented 4 years ago

Going to update ENet then. Thanks for the info.

RomanZhu commented 4 years ago

Nice, will update the repo with the new version, once it's out