Skip to content

Windows: panic: runtime error: index out of range [0] with length 0 in github.com/jackpal/gateway.DiscoverGateway() when connected to VPN #10593

Closed

Description

@darkrain42

What happened?

After upgrade from syncthing v2.0.14 to syncthing v2.0.15, syncthing panics immediately at startup if I'm connected to the VPN on my system.

  • It works fine if I disconnect the VPN and then start Syncthing, but appears to start panicking at some point after that. (I assume when the discovery functionality re-triggers).
  • It works fine if I downgrade back to v2.0.14.
  • The VPN in question is an F5 BIG-IP APM Edge client. A notable observation is that the 'route print' output reports the gateway for 0.0.0.0 as "On-link".

I suspect this correlates to the upgrade to jackpal/[email protected]. For reference, below is the lightly-obfuscated route print 0.0.0.0 output, as well as the ipconfig output for the same VPN interface.

===========================================================================
Interface List
 43..........................._Common_na_vpn
 50...00 42 42 42 42 42 ......Hyper-V Virtual Ethernet Adapter
 13...42 42 42 42 42 42 ......Intel(R) Wi-Fi otters #2
 10...42 42 42 42 42 48 ......Intel(R) Wi-Fi otters #5
 12...42 42 42 42 42 42 ......Intel(R) Wi-Fi otters
  8...42 42 42 42 42 40 ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0         On-link      192.0.2.5         1
===========================================================================
Persistent Routes:
  None

IPv6 Route Table
===========================================================================
Active Routes:
  None
Persistent Routes:
  None
Windows IP Configuration


PPP adapter _Common_na_vpn:

   Connection-specific DNS Suffix  . : example.com
   IPv6 Address. . . . . . . . . . . : fd42:4242:4242::9645
   Link-local IPv6 Address . . . . . : fe80::9645%43
   IPv4 Address. . . . . . . . . . . : 192.0.2.5
   Subnet Mask . . . . . . . . . . . : 255.255.255.255
   Default Gateway . . . . . . . . . : ::
                                       0.0.0.0

Syncthing version

2.0.15

Platform & operating system

Windows amd64

Browser version

not applicable

Relevant log output

Panic at 2026-03-06T11:15:06-08:00
panic: runtime error: index out of range [0] with length 0

goroutine 216 [running]:
github.com/jackpal/gateway.DiscoverGateway()
	github.com/jackpal/[email protected]/gateway.go:50 +0x4d
github.com/syncthing/syncthing/lib/netutil.Gateway()
	github.com/syncthing/syncthing/lib/netutil/netutil.go:29 +0x1f
github.com/syncthing/syncthing/lib/pmp.Discover.func1()
	github.com/syncthing/syncthing/lib/pmp/pmp.go:33 +0x1b
github.com/syncthing/syncthing/lib/svcutil.CallWithContext.func1()
	github.com/syncthing/syncthing/lib/svcutil/svcutil.go:231 +0x2c
created by github.com/syncthing/syncthing/lib/svcutil.CallWithContext in goroutine 213
	github.com/syncthing/syncthing/lib/svcutil/svcutil.go:230 +0xb3

[...]

goroutine 213 [select]:
github.com/syncthing/syncthing/lib/svcutil.CallWithContext({0x7ff6714bfcb0, 0xc000485310}, 0xc0003685a0)
	github.com/syncthing/syncthing/lib/svcutil/svcutil.go:234 +0xff
github.com/syncthing/syncthing/lib/pmp.Discover({0x7ff6714bfcb0, 0xc000485310}, 0x1a3185c5000, 0x2540be400)
	github.com/syncthing/syncthing/lib/pmp/pmp.go:31 +0xce
github.com/syncthing/syncthing/lib/nat.discoverAll.func1(0x0?)
	github.com/syncthing/syncthing/lib/nat/registry.go:33 +0x7f
created by github.com/syncthing/syncthing/lib/nat.discoverAll in goroutine 32
	github.com/syncthing/syncthing/lib/nat/registry.go:31 +0x95

Activity

  1. added
    bug
    needs-triage
    on Mar 6, 2026
  2. added theissue type on Mar 6, 2026
  3. marbens-arch commented on Mar 6, 2026

    @marbens-arch
    Member

    As you say, in dc2a77a (contained in 2.0.15) there was a version bump of jackpal/gateway.

    In the gateway library, there seems to be a bug that causes "success" (rather than ErrNoGateway) if all default routes have an On-link gateway, in the parseWindowsGatewayIPs function.

  4. added
    not-our-bug
    and removed
    bug
    needs-triage
    on Mar 6, 2026
  5. marbens-arch commented on Mar 6, 2026

    @marbens-arch
    Member
  6. darkrain42 commented on Mar 6, 2026

    @darkrain42
    Author

    yep, v2.0.16-rc.1.dev.3.g113cf08a (113cf08) is able to start up and run without issue. Thanks!

  7. added a commit that references this issue on Mar 29, 2026
    76f9175
  8. added 2 commits that reference this issue on Apr 6, 2026
    44ccded
    bb024c6
  9. added a commit that references this issue on Jun 28, 2026
    a4dadaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-our-bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions