yggdrasil-go icon indicating copy to clipboard operation
yggdrasil-go copied to clipboard

Finalization Yggdrasil leads to extremely high CPU consumption - possible infinite looping

Open vikulin opened this issue 3 years ago • 3 comments

Finalization Yggdrasil leads to extremely high CPU consumption - possible infinite looping.

Branch: master, fork: https://github.com/vikulin/yggdrasil-extras

The issue found while debug of Yggdrasil Android app. Also it was started after several users complained that switch off button causes high CPU consumption. As result I did profile debug and found following: The CPU starts high load right after Yggdrasil().Stop() call which is modified as following:

// Stop the mobile Yggdrasil instance
func (m *Yggdrasil) Stop() {
	logger := log.New(m.log, "", 0)
	logger.EnableLevel("info")
	logger.Infof("Stop the mobile Yggdrasil instance %s", "")
	m.admin.Stop()
	m.multicast.Stop()
	m.dummy.Stop()
	m.core.Stop()
}

The screenshot shows different states before and after the Stop() method invocation in line 256:

Before Stop() Screenshot from 2020-07-04 09-43-12

After Stop() Screenshot from 2020-07-04 09-43-35

I concern that the method Stop() runs into infinite looping somewhere within child Stop() calls.

vikulin avatar Jul 06 '20 08:07 vikulin

Maybe related: if Yggdrasil runs several days long, then stopping takes too much time:

2020/06/23 16:05:43 Starting up...
...
2020/07/04 10:56:01 Stopping multicast module
2020/07/04 10:56:01 Error reading TUN: file already closed
2020/07/04 10:56:11 Stopping...
...
2020/07/04 10:56:12 Stopped

Vort avatar Jul 06 '20 15:07 Vort

Commenting out m.admin.Stop() solved the issue, continue investigation.

// Stop the mobile Yggdrasil instance
func (m *Yggdrasil) Stop() {
	logger := log.New(m.log, "", 0)
	logger.EnableLevel("info")
	logger.Infof("Stop the mobile Yggdrasil instance %s", "")
	//m.admin.Stop()
	m.multicast.Stop()
	m.dummy.Stop()
	m.core.Stop()
}

vikulin avatar Jul 06 '20 18:07 vikulin

Found second Stop() method with the same issue: m.dummy.Stop(). I thing this is the end of my research.

vikulin avatar Jul 06 '20 19:07 vikulin

Closing as out-of-date.

neilalexander avatar Oct 21 '23 20:10 neilalexander