Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: runtime error when removing UDP server #215

Closed
zerodayyy opened this issue Apr 16, 2019 · 3 comments
Closed

panic: runtime error when removing UDP server #215

zerodayyy opened this issue Apr 16, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@zerodayyy
Copy link

zerodayyy commented Apr 16, 2019

Steps to reproduce:

  • launch with a UDP server in config
  • remove the server via API
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd1772d]

goroutine 14 [running]:
github.com/yyyar/gobetween/server/udp.(*Server).serve.func1(0xc00032e000, 0x0, 0x1, 0x0, 0x0)
        /home/yyyar/workspace/gobetween/server/udp/server.go:194 +0x2cd
created by github.com/yyyar/gobetween/server/udp.(*Server).serve
        /home/yyyar/workspace/gobetween/server/udp/server.go:187 +0xc6

Server options:

  [servers.testdns]
    max_connections = 0
    client_idle_timeout = "0"
    backend_idle_timeout = "0"
    backend_connection_timeout = "0"
    bind = "0.0.0.0:5353"
    protocol = "udp"
    balance = "roundrobin"
    [servers.testdns.udp]
      max_requests = 0
      max_responses = 1
    [servers.testdns.discovery]
      kind = "static"
      failpolicy = "keeplast"
      interval = "0"
      timeout = "0"
      static_list = ["8.8.8.8:53"]
    [servers.testdns.access]
      default = "deny"
      rules = ["allow 0.0.0.0/0"]
    [servers.testdns.healthcheck]
      kind = "none"
      interval = "0"
      passes = 1
      fails = 1
      timeout = "0"
@zerodayyy
Copy link
Author

This only happens when there are access rules defined (doesn't matter which ones though). The error is related to this line (server.go:194):
if !this.access.Allows(&clientAddr.IP) {

It is unclear though why the error only happens on server removal (everything works fine until then).

@zerodayyy
Copy link
Author

My research has shown that this issue is caused by goroutine inside serve function trying to access serverConn after it has been stopped from Start function (server.go:136: this.serverConn.Close()).
Apparent reason for this is goroutine inside serve checking this.stop variable after referencing serverConn which is deleted in this case. Going to create pull request anytime soon.

@illarion
Copy link
Collaborator

@waaayfar3r thank you for research! Waiting for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants