boramalper / magnetico

Autonomous (self-hosted) BitTorrent DHT search engine suite.
http://labs.boramalper.org/magnetico/
GNU Affero General Public License v3.0
3.06k stars 344 forks source link

Magneticod v0.7.1 always crashes after a certain time #174

Closed Fofeu closed 5 years ago

Fofeu commented 6 years ago

Magneticod always crashes with the same message Here is the log output before the crash

2018-09-26T11:15:30.786+0200    WARN    Latest status:  {"n": 2000, "maxNeighbors": 2000}
2018-09-26T11:15:30.868+0200    WARN    WRITE CONGESTION!       {"error": "operation not permitted"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x77f123]
goroutine 21 [running]:
github.com/boramalper/magnetico/cmd/magneticod/dht/mainline.(*Transport).WriteMessages(0xc000168100, 0xc0001ae6e0, 0xc000693aa8)
        /root/go/src/github.com/boramalper/magnetico/cmd/magneticod/dht/mainline/transport.go:154 +0x343
github.com/boramalper/magnetico/cmd/magneticod/dht/mainline.(*Protocol).SendMessage(0xc000176000, 0xc0001ae6e0, 0xc000693aa8)
        /root/go/src/github.com/boramalper/magnetico/cmd/magneticod/dht/mainline/protocol.go:150 +0x43
github.com/boramalper/magnetico/cmd/magneticod/dht/mainline.(*TrawlingService).findNeighbors(0xc000174000)
        /root/go/src/github.com/boramalper/magnetico/cmd/magneticod/dht/mainline/service.go:131 +0xea
github.com/boramalper/magnetico/cmd/magneticod/dht/mainline.(*TrawlingService).trawl(0xc000174000)
        /root/go/src/github.com/boramalper/magnetico/cmd/magneticod/dht/mainline/service.go:91 +0x2a8
created by github.com/boramalper/magnetico/cmd/magneticod/dht/mainline.(*TrawlingService).Start
        /root/go/src/github.com/boramalper/magnetico/cmd/magneticod/dht/mainline/service.go:69 +0x63
Glandos commented 5 years ago

I had the same behavior.

I was trying to throttle traffic a bit to please my ISP routers. I was playing with iptables, using the hashlimit module with the reject target, so my own server generate unreachable ICMP messages.

Glandos commented 5 years ago

@boramalper Correct me if I'm wrong, but on https://github.com/boramalper/magnetico/blob/b0c9198f8d90eaee01c3fe0ea89752097afaf2de/cmd/magneticod/dht/mainline/protocol.go#L39 the transport is initialized with the onCongestion function from the new Protocol instance, which have no eventHandlers yet, since it's done on the next line.

So either the two lines have to be switched, or the the transport should be initialized with:

p.transport = NewTransport(laddr, p.onMessage, eventHandlers.OnCongestion)
faddat commented 5 years ago

I had a crash, too but it was different. I wasn't recording logs at the time, but I'm making a SystemD unit so that I'll catch it next time around.

boramalper commented 5 years ago

Shall be fixed by d7bfbc71824c577d651e3d44e647bb3ac49568ef =)

Thanks @Glandos!

alcalyn commented 5 years ago

I had this issue, and it does not crash anymore with the latest version.

But I still get lot of WARN WRITE CONGESTION! {"error": "operation not permitted"}, like more than 30 per seconds

lruggieri commented 5 years ago

I had this issue, and it does not crash anymore with the latest version.

But I still get lot of WARN WRITE CONGESTION! {"error": "operation not permitted"}, like more than 30 per seconds

Hi @alcalyn,

that is likely due to not setting

iptables -I OUTPUT -t raw -p udp --sport PORT_NUMBER -j NOTRACK
iptables -I PREROUTING -t raw -p udp --dport PORT_NUMBER -j NOTRACK

as explined in magneticod readme. Some people fixed your problem with it. I still have some issue but they are likely related to some misconfiguration on my side. Try those 2 rules (PORT_NUMBER should be 0 unless you specified some custom indexer-addr parameter. In that case use the port you specified).