Wireguard iOS crashes after upgrading to XCode 14

Houman houmie at gmail.com
Thu Sep 22 09:46:34 UTC 2022


Thank you Andrej for explaining the reason. It makes sense.

Kind regards,
Houman

On Thu, 22 Sept 2022 at 10:44, Andrej Mihajlov <and at mullvad.net> wrote:
>
> Hi Houman,
>
> I believe that the crash coming from withMemoryRebound is actually assertion (assert()). Very often assertions are stripped out from release builds, so I guess it could be the reason why it just worked in release builds.
>
> Jason has already replied in regards of releasing an update.
>
> Best regards,
> Andrej
>
> > On 22 Sep 2022, at 10:56, Houman <houmie at gmail.com> wrote:
> >
> > Hi Andrej,
> >
> > It works, well done!
> >
> > A strange thing though, before your patch I was still able to connect
> > to the VPN server, if I changed the schema to Release instead of
> > Debug.  Now with your patch it also works under Debug schema, which is
> > fantastic.
> > What could be the technical reason that it still worked under Release?
> >
> > And what will happen now, are you able to actually get this patch
> > released on the official repo? The repo hasn't been updated for a
> > year.  :-)
> >
> > Thanks,
> > Houman
> >
> >
> > On Thu, 22 Sept 2022 at 09:31, Andrej Mihajlov <and at mullvad.net> wrote:
> >>
> >> Hi,
> >>
> >> I think we have a bug. If I am right, basically in both IPv4 and IPv6 extensions, withMemoryRebound takes capacity which is actually a number of instances of a given type (sockaddr_ variant) and not the byte size of a struct.
> >>
> >> Could you please patch your WireGuardKit with the following commit and see if it helps?
> >>
> >> https://git.zx2c4.com/wireguard-apple/commit/?h=am/fix-addrinfo-crash
> >>
> >> Best regards,
> >> Andrey Mikhaylov
> >>
> >>> On 13 Sep 2022, at 14:41, Houman <houmie at gmail.com> wrote:
> >>>
> >>> My existing Wireguard iOS implementation stopped working after
> >>> upgrading to Xcode 14 today.
> >>> When trying to connect to servers that support only IPv4, then it's
> >>> fine. But if the server supports both IPv6 and IPv4 then the tunnel
> >>> crashes:
> >>>
> >>> This IPv6 extension in
> >>> wireguard-apple/Sources/WireGuardKit/IPAddress+AddrInfo.swift crashes
> >>> with a Fatal Error at addrInfo.ai_addr.withMemoryRebound()
> >>>
> >>> The whole extension below:
> >>>
> >>> extension IPv6Address {
> >>>   init?(addrInfo: addrinfo) {
> >>>       guard addrInfo.ai_family == AF_INET6 else { return nil }
> >>>
> >>>       let addressData = addrInfo.ai_addr.withMemoryRebound(to:
> >>> sockaddr_in6.self, capacity: MemoryLayout<sockaddr_in6>.size) { ptr ->
> >>> Data in
> >>>           return Data(bytes: &ptr.pointee.sin6_addr, count:
> >>> MemoryLayout<in6_addr>.size)
> >>>       }
> >>>       self.init(addressData)
> >>>   }
> >>> }
> >>>
> >>> Has anyone else experienced this problem?
> >>>
> >>> Thanks,
> >>
>


More information about the WireGuard mailing list