SoftwareGuy / Ignorance

Ignorance utilizes the power of ENet to provide a reliable UDP networking transport for Mirror Networking.
Other
248 stars 31 forks source link

iOS 9.3.5 crash #50

Closed mikosaure closed 5 years ago

mikosaure commented 5 years ago

Hi there,

I'm experiencing a crash on iOS 9.3.5 (works perfect on iOS 10 and later versions) with XCode 10.2.1 and Unity 2018.3.11f1.

It crashes when I call Mirror.Ignorance:ClientConnect(String). That line: int32_t returnValue = reinterpret_cast<PInvokeFunc>(enet_host_service)(___host0, ___event1, ___timeout2);

in: Native_enet_host_service_m48FBC7FF96DFB99185B042148A1B5F95D6BD9AC6

There is not much details about the error, just:

dyld`dyld_fatal_error: -> 0x1febf08c <+0>: trap
0x1febf090 <+4>: nop

Any idea where it can come from?

Thanks a lot for your help!

SoftwareGuy commented 5 years ago

Greetings and thanks for the bug report. Sorry for the late response - apparently an email arrived about this ticket while I was asleep this morning and it failed to land in my urgent inbox folder.

Are you supplying a IP address or a host name when calling that function? If it's a host name it could be that it's trying to do a DNS lookup and failing to do so. If it's just a standard IP Address then something is weird and I might have to talk to a friend who is very fluent in C. I haven't actually used the Xcode Debugger so I'll have to get a little antiquated with it.

As for iOS 9.3.5, That's definitely an older version of iOS that you're lucky that I actually have a device that supports said version iOS - I believe a 3G + WiFi iPad 2. Or a duo of iPhone 4S units.

Would you happen to be able to share a repro project or any scripts/instructions on how to get it to crash on iOS? Or do you want me to compile for iOS with the included Pong example and see if that craps itself?

mikosaure commented 5 years ago

Hey there!

thanks for getting back to me.

I'm supplying an IP address. I was able to reproduce the problem with a minimal project: Mirror package + Ignorance and running the "Basic" example from Mirror. Just type an IP address then LAN Client, and it'll crash right after the log "Ignorance successfully initialized ENET.".

Definitely an old version of iOS and unfortunately these iPads can't update to a newer version :(

Thanks a lot for your help. Mike

Le jeu. 22 août 2019 à 04:51, Coburn notifications@github.com a écrit :

Greetings and thanks for the bug report. Sorry for the late response - apparently an email arrived while I was asleep this morning and it failed to land in my urgent inbox folder.

Are you supplying a IP address or a hostname when calling that function? If it's a host name it could be that it's trying to do a DNS lookup and failing to do so. If it's just a standard IP Address then something is weird and I might have to talk to a friend who is very fluent in C. I haven't actually used the Xcode Debugger so I'll have to get a little antiquated with it.

As for iOS 9.3.5, That's definitely an older version of iOS that you're lucky that I actually have a device that supports said version iOS - I believe a 3G + WiFi iPad 2. Or a duo of iPhone 4S units.

Would you happen to be able to share a repro project or any scripts/instructions on how to get it to crash on iOS? Or do you want me to compile for iOS with the included Pong example and see if that craps itself?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SoftwareGuy/Ignorance/issues/50?email_source=notifications&email_token=AM62UAPQ7NDQ5B5OQ2SH7PDQFZ4SXA5CNFSM4IOLSDFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD442MLI#issuecomment-523871789, or mute the thread https://github.com/notifications/unsubscribe-auth/AM62UAKOVNYYZQKGBD7YDBLQFZ4SXANCNFSM4IOLSDFA .

SoftwareGuy commented 5 years ago

Excellent, thanks for that information.

I am currently in the throws of putting together a repro project, just waiting for the iOS module of unity to finish installing and I'll throw it across to the iPad 2 I have attached to my Macbook Pro.

Will update when I attempt to replicate this failure.

SoftwareGuy commented 5 years ago

Okay, I tracked it down and it's due to ENET assuming availability of the monotonic clock_gettime(...) call. On things previous to iOS 10, this causes a E_ARM_BREAKPOINT exception that XCode catches in the debugger and provides a stack trace. I also noticed the same issue here in this Stack Overflow issue.

This will be fixed in the ENET source code contained my fork of ENET-CSharp and will be included in the release of Ignorance 1.3.2+.

I must say that this was a interesting bug as I realize some older iOS devices might be sentimental to some developers and/or you have to support a user/client base that use a lot of old versions.

SoftwareGuy commented 5 years ago

Here's the replacement libenet.a file you'll need if you don't want to wait for a new release of Ignorance. Simply use this one rather than the one that ships with Ignorance.

Enet_PreIOS10_FixedPlugin.zip

Please let me know how this works and I'll close the ticket after marking as resolved.

mikosaure commented 5 years ago

I've tried to replace the libenet.a file with the new one but now it doesn't link anymore with the following error:

Undefined symbols for architecture armv7: "_enet_host_broadcast_excluding", referenced from: _Host_Broadcast_mBD17441DEEB7307BC68418776F7C860932A1E545 in Bulk_Mirror_0.o _Native_enet_host_broadcast_excluding_mC3547C283B7DFB5F57C408D67E3337816F029D31 in Bulk_Mirror_0.o (maybe you meant: _Native_enet_host_broadcast_excluding_mC3547C283B7DFB5F57C408D67E3337816F029D31) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea how to fix that?

SoftwareGuy commented 5 years ago

That's really strange...

Let me check the iOS ENET Build Environment again. I might have forgotten an architecture or something silly.

SoftwareGuy commented 5 years ago

Please try this binary, I built it without debug and as MinSizeRel which is a stripped release build.

I replaced the file in the Plugins folder in Ignorance and clicked "Build" in the Unity Build Settings. It spat out a project that compiled, linked and installed onto a test iPhone 4S running OS version 9.3.5 just fine.

As you can see if you run lipo -archs on the library:

$ lipo -archs libenet.a
armv7 armv7s arm64 arm64e 

It's definitely there, maybe Xcode cache messed up? libenet_recompile.zip

mikosaure commented 5 years ago

Very strange: I still have the same problem with the new one. Looks like the symbol _enet_host_broadcast_excluding is missing. When I do nm -a on the old file I find the symbols but not on the new one?

SoftwareGuy commented 5 years ago

Hrm.... let me talk to my C programmer friend and I'll get back to you on this. I'm stumped as well.

c6burns commented 5 years ago

Hey gang, something is getting mismatched here. The symbol should be: enet_host_broadcast_exclude And not: enet_host_broadcast_excluding

Native: https://github.com/SoftwareGuy/ENet-CSharp/blob/master/Source/Native/enet.h#L736 Managed: https://github.com/SoftwareGuy/ENet-CSharp/blob/master/Source/Managed/ENet.cs#L983

And it's updated in Ignorance master: https://github.com/SoftwareGuy/Ignorance/blob/master/Assets/Mirror/Runtime/Transport/Ignorance/Dependencies/ENet.cs#L983

So it looks like you are missing this commit in Ignorance: https://github.com/SoftwareGuy/Ignorance/commit/9857de28f61ae2198225438ef974a023f5b70f1b

It definitely was excluding but should now be excluded

mikosaure commented 5 years ago

Yes!! It's working fine with that commit and updated library (and also the other commit to fix the server bug). Looks like everything is great now! Thanks a lot

SoftwareGuy commented 5 years ago

Will mark this as resolved and close, please don’t hesitate to reopen if the problem comes back. 🙂