Skip to content

portmapper: [unexpected] no error but no stored mapping then nil pointer dereference #10911

Closed

Description

@Andrew-Bekhiet

What is the issue?

Tailscaled service keeps restarting with last log lines like this:

magicsock: derp-18 connected; connGen=1
health("overall"): ok
control: successful lite map update in 180ms
portmapper: [unexpected] no error but no stored mapping: now=1705787071 external=invalid AddrPort type=none
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc08810]

goroutine 589 [running]:
tailscale.com/net/portmapper.addAnyPortMapping({0x11e8bb0?, 0xc003ebe9c0?}, {0x0?, 0x0?}, 0xa6c0?, 0x3b3?, {0xc004066000?, 0xc?}, 0x68c61714000?)
        [email protected]/net/portmapper/upnp.go:189 +0x190
tailscale.com/net/portmapper.(*Client).tryUPnPPortmapWithDevice(0xc00021c000, {0x11e8bb0, 0xc003ebe9c0}, {{{0x25?, 0xc0004f58e0?}, 0xc000010018?}, 0x4f60?}, 0x5a?, 0x11e8bb0?, 0xc003b3a6c0)
        [email protected]/net/portmapper/upnp.go:564 +0xe5
tailscale.com/net/portmapper.(*Client).getUPnPPortMapping(0xc00021c000, {0x11e8c58, 0xc003b40a10}, {{0x0?, 0x0?}, 0xc000010018?}, {{{0x0, 0xffffc0a8010f}, 0xc000010018}, 0x9f06}, ...)
        [email protected]/net/portmapper/upnp.go:506 +0x9f5
tailscale.com/net/portmapper.(*Client).createOrGetMapping(0xc00021c000, {0x11e8c58?, 0xc003b40a10?})
        [email protected]/net/portmapper/portmapper.go:567 +0x95c
tailscale.com/net/portmapper.(*Client).createMapping(0xc00021c000)
        [email protected]/net/portmapper/portmapper.go:451 +0x85
created by tailscale.com/net/portmapper.(*Client).maybeStartMappingLocked in goroutine 60
        [email protected]/net/portmapper/portmapper.go:437 +0x59

Steps to reproduce

sudo tailscale up

Are there any recent changes that introduced the issue?

I don't know but I only noticed this recently

OS

Linux

OS version

Ubuntu 23.10 x86_64

Tailscale version

1.58.0

Other software

none

Bug report

BUG-247513147679d295daa4af26c1e1a76a94b05d9061d1f5d87ddf9068ebbe1c8f-20240120215225Z-4a1a8325602c19ba

Activity

  1. bradfitz commented on Jan 20, 2024

    @bradfitz
    Member
  2. bradfitz commented on Jan 20, 2024

    @bradfitz
    Member

    tailscale.com/net/portmapper.addAnyPortMapping({0x11e8bb0?, 0xc003ebe9c0?}, {0x0?, 0x0?}

    That {0x0?, 0x0?} means the upnp upnpClient is a nil interface.

    Looks like selectBestService can return (nil, nil) which isn't really documented and might be (or have been) surprising to callers:

            // If we have no clients, then return right now; if we only have one,                                           
            // just select and return it.                                                                                   
            if len(clients) == 0 {
                    return nil, nil
            }
  3. Andrew-Bekhiet commented on Jan 20, 2024

    @Andrew-Bekhiet
    Author

    I've noticed that on downgrading to tailscale 1.56.1, logging out then logging in again solves it

  4. added
    L4 Most users
    P5 Halts deployment
    T8 Crash
    and removed on Jan 21, 2024
  5. DentonGentry commented on Jan 21, 2024

    @DentonGentry
    Contributor

    Can you say what kind of router you're using, like cable modem or Fiber-to-the-Home router?
    What it sends in its UPnP / NAT-PMP / PCP response may be important in this.

  6. Andrew-Bekhiet commented on Jan 21, 2024

    @Andrew-Bekhiet
    Author

    It's a cable modem, connected over wifi
    How can I help with getting the UPnP / NAT / PMP / PCP responses?

  7. DentonGentry commented on Jan 21, 2024

    @DentonGentry
    Contributor

    How can I help with getting the UPnP / NAT / PMP / PCP responses?

    If you are comfortable using Wireshark, you can:

    • use a filter of "ssdp" (look at the green bar at the top of this screenshot for an example)
    • capture frames until you see an M-SEARCH request followed by responses, then hit the red button at the top to stop capture.
    Capturing
    • hit control-A or command-A to select all packets in the display. In the bottom right you should see a relatively small number of packets selected, out of a large number captured.
    Selecting
    • Choose File > Export Specified Packets, then choose selected packets only.
    Exporting

    You can compress the pcapng file to zip to attach it here. If not comfortable attaching it to a public bug report, you can email it to [email protected] and please mention bug 10911.

  8. Andrew-Bekhiet commented on Jan 21, 2024

    @Andrew-Bekhiet
    Author

    I've sent the packets by email

  9. 7 remaining items

  10. andrew-d commented on Jan 22, 2024

    @andrew-d
    Member

    #10922 includes a fix for this issue, and will be included in 1.58.1 when we build that. I expect that we'll build that version soon, and we will post here when we do so.

  11. Andrew-Bekhiet commented on Jan 22, 2024

    @Andrew-Bekhiet
    Author

    Awesome!

  12. Andrew-Bekhiet commented on Jan 23, 2024

    @Andrew-Bekhiet
    Author

    Don't know if it's relevant but today I found out that my UPnP setting is disabled in my router, so I've enabled it, does that make any difference?

  13. agottardo commented on Feb 13, 2024

    @agottardo
    Contributor

    Closing because the issue has been resolved in v1.58.2.

  14. added a commit that references this issue on Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

L4 Most usersP5 Halts deploymentT8 Crashbugneeds-fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions