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

Concurrent map writes panic #514

Closed
nkryuchkov opened this issue Sep 9, 2020 · 0 comments · Fixed by #515
Closed

Concurrent map writes panic #514

nkryuchkov opened this issue Sep 9, 2020 · 0 comments · Fixed by #515
Assignees
Labels
bug Something isn't working

Comments

@nkryuchkov
Copy link
Contributor

Describe the bug
Sometimes visor panics on shutdown with fatal error: concurrent map writes

Environment information:

  • The issue does not depend on the environment.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Run visor
  2. Press Ctrl-C at a certain moment

Actual behavior
Visor panics

Expected behavior
Visor does not panic

Additional context

[2020-09-09T21:26:03+03:00] INFO [snet.dmsgC]: Cleanly stopped serving. dmsgpty="host" error="dmsg error 200 - local entity closed"
[2020-09-09T21:26:03+03:00] INFO [4/11] [visor:shutdown:dmsgpty.serve]: Module stopped cleanly. elapsed=456.379µs 
[2020-09-09T21:26:03+03:00] INFO [3/11] [visor:shutdown:snet.dmsgctrl]: Shutting down module...                                                                                                                                      
[2020-09-09T21:26:03+03:00] INFO [3/11] [visor:shutdown:snet.dmsgctrl]: Module stopped cleanly. elapsed=21.254µs                                                                                                                     
[2020-09-09T21:26:03+03:00] INFO [2/11] [visor:shutdown:snet]: Shutting down module...                                                                                                                                               
fatal error: concurrent map writes                                                                                                                                                                                                   
[2020-09-09T21:26:03+03:00] INFO [snet.dmsgC]: Stopped serving client!                                                                                                                                                               
                                                                                                                                                                                                                                     
goroutine 273 [running]:                                                                                          
runtime.throw(0x1a23510, 0x15)                                                                                                                                                                                                       
        /usr/local/Cellar/go/1.14.5/libexec/src/runtime/panic.go:1116 +0x72 fp=0xc0005a7710 sp=0xc0005a76e0 pc=0x1033eb2                                                 
runtime.mapassign_faststr(0x18e3ae0, 0xc000203200, 0x1a15c90, 0x5, 0xc00009ae70)                                                                                                                                                     
        /usr/local/Cellar/go/1.14.5/libexec/src/runtime/map_faststr.go:211 +0x3f7 fp=0xc0005a7778 sp=0xc0005a7710 pc=0x10132f7                                               
github.com/skycoin/skywire/pkg/snet.(*Network).Close.func2(0xc00026cb50, 0xc000203200, 0xc00026cb40, 0xc000496594)                                                        
        /Users/nkryuchkov/GolandProjects/skywire/pkg/snet/network.go:308 +0x7b fp=0xc0005a77c0 sp=0xc0005a7778 pc=0x161c71b
runtime.goexit()                                                                                                                                                                                                                     
        /usr/local/Cellar/go/1.14.5/libexec/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc0005a77c8 sp=0xc0005a77c0 pc=0x1066771            
created by github.com/skycoin/skywire/pkg/snet.(*Network).Close                                                   
        /Users/nkryuchkov/GolandProjects/skywire/pkg/snet/network.go:307 +0x24f                                                                                                                                                      
                                                                                                                  
goroutine 1 [select]:                                                                                                                                                                                                                
github.com/skycoin/skywire/pkg/visor.(*Visor).Close(0xc000151040, 0x0, 0x1b7e380)                                                                                                                                                    
        /Users/nkryuchkov/GolandProjects/skywire/pkg/visor/visor.go:198 +0x568                                    
github.com/skycoin/skywire/cmd/skywire-visor/commands.glob..func1(0x22eb220, 0xc000148380, 0x0, 0x4)              
        /Users/nkryuchkov/GolandProjects/skywire/cmd/skywire-visor/commands/root.go:121 +0x56d                                                                                                                                       
github.com/spf13/cobra.(*Command).execute(0x22eb220, 0xc00019a010, 0x4, 0x4, 0x22eb220, 0xc00019a010)                                                                                                                                
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/spf13/cobra/command.go:846 +0x29d              
github.com/spf13/cobra.(*Command).ExecuteC(0x22eb220, 0x10431ba, 0x2173060, 0xc00005a778)                         
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/spf13/cobra/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)                                                                    
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/spf13/cobra/command.go:887                     
github.com/skycoin/skywire/cmd/skywire-visor/commands.Execute()                                                   
        /Users/nkryuchkov/GolandProjects/skywire/cmd/skywire-visor/commands/root.go:130 +0x31                                                                                                                                        
main.main()                                                                                                                                                                                                                          
        /Users/nkryuchkov/GolandProjects/skywire/cmd/skywire-visor/skywire-visor.go:11 +0x20                      
                                                                                                                                                                                                                                     
goroutine 7 [select, 2 minutes]:                                                                                                                                                                                                     
github.com/xtaci/kcp-go.(*Listener).AcceptKCP(0xc000388630, 0x0, 0xc00010e8a0, 0x0)                                                                                                                                                  
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/sess.go:900 +0x19a   
github.com/xtaci/kcp-go.(*Listener).Accept(0xc000388630, 0x0, 0x0, 0x0, 0x0)                                   
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/sess.go:890 +0x2b      
github.com/skycoin/skywire/pkg/snet/directtp.(*client).acceptConn(0xc000390500, 0x1a23732, 0x15)         
        /Users/nkryuchkov/GolandProjects/skywire/pkg/snet/directtp/client.go:186 +0x6e                            
github.com/skycoin/skywire/pkg/snet/directtp.(*client).Serve.func1(0xc000390500)                                                                                                                                                     
        /Users/nkryuchkov/GolandProjects/skywire/pkg/snet/directtp/client.go:142 +0x197                           
created by github.com/skycoin/skywire/pkg/snet/directtp.(*client).Serve                                                                                                                                                              
        /Users/nkryuchkov/GolandProjects/skywire/pkg/snet/directtp/client.go:115 +0x62                                                                                                                                               
                                                                                                                                                                                                                                     
goroutine 12 [select]:                                                                                            
github.com/xtaci/kcp-go.(*UDPSession).updater(0xc000328000)                                                       
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/sess.go:585 +0xe2                                                                                                                                    
created by github.com/xtaci/kcp-go.newUDPSession                                                                                                                                                                                     
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/sess.go:185 +0x4e9                
                                                                                                                                                                                                                                     
goroutine 11 [runnable]:                                                                                          
runtime.Callers(...)                                                                                                                                                                                                                 
        /usr/local/Cellar/go/1.14.5/libexec/src/runtime/extern.go:215                                                                                                                                                                
github.com/pkg/errors.callers(0xc0000402c0)                                                                                                                                                                                          
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/pkg/errors/stack.go:136 +0x5b                                                                                                                                     
github.com/pkg/errors.WithStack(...)                                                                              
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/pkg/errors/errors.go:151                       
github.com/xtaci/kcp-go.(*UDPSession).defaultReadLoop(0xc000328000)                                               
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/readloop.go:28 +0x1fc             
github.com/xtaci/kcp-go.(*UDPSession).readLoop(0xc000328000)                                                                                                                                                                         
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/readloop_generic.go:6 +0x2b
created by github.com/xtaci/kcp-go.newUDPSession                                                                                                                                                                                     
        /Users/nkryuchkov/GolandProjects/skywire/vendor/github.com/xtaci/kcp-go/sess.go:178 +0x552  

Possible implementation
Add a mutex to map

@nkryuchkov nkryuchkov added the bug Something isn't working label Sep 9, 2020
@nkryuchkov nkryuchkov self-assigned this Sep 9, 2020
@nkryuchkov nkryuchkov linked a pull request Sep 9, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants