Skip to content

Commit

Permalink
Remerged with mainnet. Solved data race on NodeC
Browse files Browse the repository at this point in the history
Panic on NodeB:
```log
2019-05-30T13:10:27+03:00] INFO [trmanager]: Closing transport manager
[2019-05-30T13:10:28+03:00] INFO [skywire]: router stopped successfully
[2019-05-30T13:10:28+03:00] INFO [messenger]: Opened new link with the server 035915c609f71d0c7df27df85ec698ceca0cb262590a54f732e3bbd0cc68d89282
[2019-05-30T13:10:28+03:00] INFO [messenger]: Updating discovery entry
[2019-05-30T13:10:28+03:00] INFO [messenger]: Opened new link with the server 035915c609f71d0c7df27df85ec698ceca0cb262590a54f732e3bbd0cc68d89282
[2019-05-30T13:10:28+03:00] INFO [messenger]: Updating discovery entry
[2019-05-30T13:10:28+03:00] WARN [messenger]: Failed to send frame to 035915c609f71d0c7df27df85ec698ceca0cb262590a54f732e3bbd0cc68d89282: noise handshake: chacha20poly1305: message authentication failed
[2019-05-30T13:10:28+03:00] INFO [messenger]: Opened new channel local ID 0, remote ID 0 with 031b80cd5773143a39d940dc0710b93dcccc262a85108018a7a95ab9af734f8055
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9bafe8]

goroutine 99 [running]:
github.com/flynn/noise.(*CipherState).Cipher(...)
        /home/isk/go/pkg/mod/github.com/flynn/[email protected]/state.go:61
github.com/skycoin/skywire/internal/noise.(*Noise).EncryptUnsafe(0xc00015d520, 0xc00048a000, 0x208, 0x30a, 0xc00000fec0, 0xc0002b18f0, 0x589e93)
        /home/isk/github.com/skycoin/src/skywire/internal/noise/noise.go:131 +0x1b8
github.com/skycoin/skywire/pkg/messaging.(*msgChannel).Write(0xc0001346e0, 0xc00048a000, 0x208, 0x30a, 0x0, 0x0, 0x99c314f9b87fe5f2)
        /home/isk/github.com/skycoin/src/skywire/pkg/messaging/channel.go:131 +0x310
encoding/json.(*Encoder).Encode(0xc0002b1ef0, 0xbdeda0, 0xc0001b4640, 0x7fb6144c7350, 0xc0001346e0)
        /usr/lib/go/src/encoding/json/stream.go:225 +0x241
github.com/skycoin/skywire/pkg/transport.settlementInitiatorHandshake.func1(0xc0001ee140, 0xd594e0, 0xc0001346e0, 0x0, 0x0, 0x0)
        /home/isk/github.com/skycoin/src/skywire/pkg/transport/handshake.go:46 +0x8d2
github.com/skycoin/skywire/pkg/transport.settlementHandshake.Do.func1(0xc000456e90, 0xc0001ee140, 0xd594e0, 0xc0001346e0, 0xc0001881a8, 0xc000186ed0, 0xc000429800)
        /home/isk/github.com/skycoin/src/skywire/pkg/transport/handshake.go:18 +0x56
created by github.com/skycoin/skywire/pkg/transport.settlementHandshake.Do
        /home/isk/github.com/skycoin/src/skywire/pkg/transport/handshake.go:17 +0x108
```
  • Loading branch information
ayuryshev committed May 30, 2019
1 parent 574605f commit 536d999
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ func (r *Router) Serve(ctx context.Context) error {

go func() {
for tp := range r.tm.TrChan {
r.mu.Lock()
isAccepted, isSetup := tp.Accepted, r.IsSetupTransport(tp)
r.mu.Unlock()

var serve func(io.ReadWriter) error
switch {
Expand Down
7 changes: 4 additions & 3 deletions pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (tm *Manager) DeleteTransport(id uuid.UUID) error {
tm.Logger.Warnf("Failed to change transport status: %s", err)
}

tm.Logger.Infof("De-registered transport %s", id)
tm.Logger.Infof("Unregistered transport %s", id)
if tr != nil {
return tr.Close()
}
Expand All @@ -268,6 +268,7 @@ func (tm *Manager) Close() error {
continue
}
statuses = append(statuses, &Status{ID: tr.ID, IsUp: false})

tr.Close()
}
tm.transports = make(map[uuid.UUID]*ManagedTransport)
Expand Down Expand Up @@ -393,14 +394,14 @@ func (tm *Manager) manageTransport(ctx context.Context, managedTr *ManagedTransp
tm.Logger.Infof("Transport %s failed with error: %s. Re-dialing...", managedTr.ID, err)
if accepted {
if err := tm.DeleteTransport(managedTr.ID); err != nil {
tm.Logger.Warnf("Failed to delete transport: %s", err)
tm.Logger.Warnf("Failed to delete accepted transport: %s", err)
}
} else {
tr, _, err := tm.dialTransport(ctx, factory, remote, public)
if err != nil {
tm.Logger.Infof("Failed to re-dial Transport %s: %s", managedTr.ID, err)
if err := tm.DeleteTransport(managedTr.ID); err != nil {
tm.Logger.Warnf("Failed to delete transport: %s", err)
tm.Logger.Warnf("Failed to delete re-dialled transport: %s", err)
}
} else {
managedTr.updateTransport(tr)
Expand Down

0 comments on commit 536d999

Please sign in to comment.