Development discussion of WireGuard
 help / color / mirror / Atom feed
* Wireguard iOS crashes after upgrading to XCode 14
@ 2022-09-13 12:41 Houman
  2022-09-22  8:31 ` Andrej Mihajlov
  0 siblings, 1 reply; 9+ messages in thread
From: Houman @ 2022-09-13 12:41 UTC (permalink / raw)
  To: WireGuard mailing list

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,

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-13 12:41 Wireguard iOS crashes after upgrading to XCode 14 Houman
@ 2022-09-22  8:31 ` Andrej Mihajlov
  2022-09-22  8:56   ` Houman
  0 siblings, 1 reply; 9+ messages in thread
From: Andrej Mihajlov @ 2022-09-22  8:31 UTC (permalink / raw)
  To: Houman; +Cc: WireGuard mailing list

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@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,


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  8:31 ` Andrej Mihajlov
@ 2022-09-22  8:56   ` Houman
  2022-09-22  9:38     ` Jason A. Donenfeld
  2022-09-22  9:44     ` Andrej Mihajlov
  0 siblings, 2 replies; 9+ messages in thread
From: Houman @ 2022-09-22  8:56 UTC (permalink / raw)
  To: Andrej Mihajlov; +Cc: WireGuard mailing list

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@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@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,
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  8:56   ` Houman
@ 2022-09-22  9:38     ` Jason A. Donenfeld
  2022-09-22  9:39       ` Houman
  2022-12-05 17:15       ` Houman
  2022-09-22  9:44     ` Andrej Mihajlov
  1 sibling, 2 replies; 9+ messages in thread
From: Jason A. Donenfeld @ 2022-09-22  9:38 UTC (permalink / raw)
  To: Houman; +Cc: Andrej Mihajlov, WireGuard mailing list

On 9/22/22, Houman <houmie@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.  :-)
>

Yeah, I'll circle back Apple development at some point. No worries.

Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  9:38     ` Jason A. Donenfeld
@ 2022-09-22  9:39       ` Houman
  2022-12-05 17:15       ` Houman
  1 sibling, 0 replies; 9+ messages in thread
From: Houman @ 2022-09-22  9:39 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Andrej Mihajlov, WireGuard mailing list

Sounds good, thanks, Jason.

On Thu, 22 Sept 2022 at 10:38, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> On 9/22/22, Houman <houmie@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.  :-)
> >
>
> Yeah, I'll circle back Apple development at some point. No worries.
>
> Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  8:56   ` Houman
  2022-09-22  9:38     ` Jason A. Donenfeld
@ 2022-09-22  9:44     ` Andrej Mihajlov
  2022-09-22  9:46       ` Houman
  1 sibling, 1 reply; 9+ messages in thread
From: Andrej Mihajlov @ 2022-09-22  9:44 UTC (permalink / raw)
  To: Houman; +Cc: WireGuard mailing list

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@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@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@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,
>> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  9:44     ` Andrej Mihajlov
@ 2022-09-22  9:46       ` Houman
  0 siblings, 0 replies; 9+ messages in thread
From: Houman @ 2022-09-22  9:46 UTC (permalink / raw)
  To: Andrej Mihajlov; +Cc: WireGuard mailing list

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

Kind regards,
Houman

On Thu, 22 Sept 2022 at 10:44, Andrej Mihajlov <and@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@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@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@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,
> >>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-09-22  9:38     ` Jason A. Donenfeld
  2022-09-22  9:39       ` Houman
@ 2022-12-05 17:15       ` Houman
  2022-12-05 17:40         ` Jason A. Donenfeld
  1 sibling, 1 reply; 9+ messages in thread
From: Houman @ 2022-12-05 17:15 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Andrej Mihajlov, WireGuard mailing list

Hi Jason,

I was wondering if there are still any plans to focus on the Apple
development and bring the repo more up-to-date, please.

Since the latest major development on the Wireguard Linux repo seems
to have finished by 31st October, I was wondering if Apple dev could
be prioritised next, please.

I can see there was an update to the License file a couple of weeks
ago. But the last real commit on Apple repo is from Sep 2021.

Many Thanks,
Houman


On Thu, 22 Sept 2022 at 10:38, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> On 9/22/22, Houman <houmie@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.  :-)
> >
>
> Yeah, I'll circle back Apple development at some point. No worries.
>
> Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Wireguard iOS crashes after upgrading to XCode 14
  2022-12-05 17:15       ` Houman
@ 2022-12-05 17:40         ` Jason A. Donenfeld
  0 siblings, 0 replies; 9+ messages in thread
From: Jason A. Donenfeld @ 2022-12-05 17:40 UTC (permalink / raw)
  To: Houman; +Cc: Andrej Mihajlov, WireGuard mailing list

On Mon, Dec 5, 2022 at 6:15 PM Houman <houmie@gmail.com> wrote:
>
> Hi Jason,
>
> I was wondering if there are still any plans to focus on the Apple
> development and bring the repo more up-to-date, please.
>
> Since the latest major development on the Wireguard Linux repo seems
> to have finished by 31st October, I was wondering if Apple dev could
> be prioritised next, please.
>
> I can see there was an update to the License file a couple of weeks
> ago. But the last real commit on Apple repo is from Sep 2021.

Yes that's the next priority.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-05 17:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 12:41 Wireguard iOS crashes after upgrading to XCode 14 Houman
2022-09-22  8:31 ` Andrej Mihajlov
2022-09-22  8:56   ` Houman
2022-09-22  9:38     ` Jason A. Donenfeld
2022-09-22  9:39       ` Houman
2022-12-05 17:15       ` Houman
2022-12-05 17:40         ` Jason A. Donenfeld
2022-09-22  9:44     ` Andrej Mihajlov
2022-09-22  9:46       ` Houman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).