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 in net/swarm/conn.go:154 was triggered #174

Closed
whyrusleeping opened this issue Oct 14, 2014 · 4 comments
Closed

panic in net/swarm/conn.go:154 was triggered #174

whyrusleeping opened this issue Oct 14, 2014 · 4 comments
Assignees
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@whyrusleeping
Copy link
Member

Was running a dhtHell test (albeit a larger one) and came across this panic.

dhtHell config:

60
[4-59]->[0-3]
--
57 store key value
57 provide key
[11-52] get key
==
@whyrusleeping whyrusleeping added the kind/bug A bug in existing code (including security flaws) label Oct 14, 2014
@whyrusleeping
Copy link
Member Author

Logs leading up to the panic:

�[31m2014-10-14 11:22:51.523365 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.525323 service.go:236 ERROR: �[0mno request key 18 32 101 179 53 106 11 80 157 186 142 15 85 163 178 20 116 88 173 91 242 156 23 53 248 175 167 153 175 207 120 68 28 74 90 85 249 75
�[31m2014-10-14 11:22:51.575388 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.589432 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.621984 dht.go:329 ERROR: �[0mgetFromPeers error: context canceled
�[31m2014-10-14 11:22:51.62677 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.661961 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.68675 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.689547 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.701601 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.
�[31m2014-10-14 11:22:51.715659 dht.go:323 ERROR: �[0mgetFromPeers error: Error: Connection to this peer already open.

@whyrusleeping
Copy link
Member Author

This appears to be caused by two different peers trying to connect to eachother at the same time as a result of everyone trying to get the same value.

@jbenet
Copy link
Member

jbenet commented Oct 20, 2014

Found. It.


This was annoying. Took me way too long. And i got rid of it for a long time, but then resurfaced. Turns out the problem was a bad combination of Dial + Listen. (a peer would dial out and receive a connection from the same peer at the same time, ending with two Peer objectS). I got rid of it in the codebase, but surfaced in the tests, then fixed it.

// Dial connects to a particular peer, over a given network
// Example: d.Dial(ctx, "udp", peer)
func (d *Dialer) Dial(ctx context.Context, network string, remote peer.Peer) (Conn, error) {
    laddr := d.LocalPeer.NetAddress(network)
    if laddr == nil {
        return nil, fmt.Errorf("No local address for network %s", network)
    }

    raddr := remote.NetAddress(network)
    if raddr == nil {
        return nil, fmt.Errorf("No remote address for network %s", network)
    }

    // TODO: try to get reusing addr/ports to work.
    // madialer := manet.Dialer{LocalAddr: laddr}
    madialer := manet.Dialer{}

    log.Info("%s dialing %s %s", d.LocalPeer, remote, raddr)
    maconn, err := madialer.Dial(raddr)
    if err != nil {
        return nil, err
    }

// THIS. remote here is the value the function was called with. but after waiting
// on madialer.Dial, a new peer might have been added to Peerstore by Listen 
    if err := d.Peerstore.Put(remote); err != nil {
        log.Error("Error putting peer into peerstore: %s", remote)
    }

    c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn)
    if err != nil {
        return nil, err
    }

    return newSecureConn(ctx, c, d.Peerstore)
}

@whyrusleeping
Copy link
Member Author

image

ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this issue Oct 23, 2021
Changed lots of peer use, and changed the peerstore to ensure
there is only ever one peer in use.

Fixed ipfs#174
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this issue Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

No branches or pull requests

2 participants